glom r1462 - in trunk: . glom/libglom/data_structure



Author: murrayc
Date: Tue Mar 18 17:44:03 2008
New Revision: 1462
URL: http://svn.gnome.org/viewvc/glom?rev=1462&view=rev

Log:
2008-03-18  Murray Cumming  <murrayc murrayc com>

* glom/libglom/data_structure/fieldtypes.cc 
get_string_name_for_gdavaluetype(): Hard-code the result for 
text fields (G_TYPE_STRING) so we always use varchar. Otherwise 
we mistakenly create fields of type xml because libgda reports many 
postgres 8.3 fields types as being of type G_TYPE_STRING.


Modified:
   trunk/ChangeLog
   trunk/glom/libglom/data_structure/fieldtypes.cc

Modified: trunk/glom/libglom/data_structure/fieldtypes.cc
==============================================================================
--- trunk/glom/libglom/data_structure/fieldtypes.cc	(original)
+++ trunk/glom/libglom/data_structure/fieldtypes.cc	Tue Mar 18 17:44:03 2008
@@ -59,7 +59,7 @@
       int rows = data_model_tables->get_n_rows();
       for(int i = 0; i < rows; ++i)
       {
-        Gnome::Gda::Value value_name = data_model_tables->get_value_at(DATAMODEL_FIELDS_COL_NAME, i);
+        const Gnome::Gda::Value value_name = data_model_tables->get_value_at(DATAMODEL_FIELDS_COL_NAME, i);
 
         //Get the types's string representation:
         Glib::ustring schema_type_string;
@@ -74,6 +74,8 @@
             const GType gdatype = static_cast<GType>(value_gdatype.get_ulong());
 
             //Save it for later:
+            //std::cout << "debug: schema_type_string=" << schema_type_string << ", gda type=" << gdatype << "(" << g_type_name(gdatype) << ")" << std::endl;
+            
             m_mapSchemaStringsToGdaTypes[schema_type_string] = gdatype;
 
             Glib::ustring gdatypestring = gda_g_type_to_string(gdatype); // TODO: What is this actually used for?
@@ -105,6 +107,12 @@
 
 Glib::ustring FieldTypes::get_string_name_for_gdavaluetype(GType field_type) const
 {
+  //Special-case gchararray (G_TYPE_STRING) because Gda reports this GType for several 
+  //postgres field types (xml, inet, tinterval, etc),
+  //though we only care about varchar:
+  if(field_type == G_TYPE_STRING)
+    return "varchar";
+
   type_mapGdaTypesToSchemaStrings::const_iterator iterFind = m_mapGdaTypesToSchemaStrings.find(field_type);
   if(iterFind == m_mapGdaTypesToSchemaStrings.end())
   {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]