glom r1860 - in trunk: . glom glom/libglom/data_structure glom/mode_data glom/mode_design/fields glom/mode_design/print_layouts



Author: jhs
Date: Mon Jan 26 16:52:30 2009
New Revision: 1860
URL: http://svn.gnome.org/viewvc/glom?rev=1860&view=rev

Log:
2009-01-26  Johannes Schmid  <jschmid openismus com>

	* glom/base_db.cc:
	* glom/base_db.h:
	Ported more queries to use parameters. query_execute_select() now
	accepts parameters.
	
	* glom/base_db_table_data.cc:
	* glom/dialog_database_preferences.cc:
	* glom/frame_glom.cc:
	* glom/mode_data/box_data.cc:
	* glom/mode_data/box_data_calendar_related.cc:
	* glom/mode_data/box_data_details.cc:
	* glom/mode_design/fields/box_db_table_definition.cc:
	* glom/mode_design/print_layouts/canvas_print_layout.cc:
	Removed parent_window argument from query_execute_select() call.
		
	* glom/libglom/data_structure/field.cc:
	* glom/libglom/data_structure/field.h:
	Added get_holder() und get_gda_holder_string() as conveniece methods

Modified:
   trunk/ChangeLog
   trunk/glom/base_db.cc
   trunk/glom/base_db.h
   trunk/glom/base_db_table_data.cc
   trunk/glom/dialog_database_preferences.cc
   trunk/glom/frame_glom.cc
   trunk/glom/libglom/data_structure/field.cc
   trunk/glom/libglom/data_structure/field.h
   trunk/glom/mode_data/box_data.cc
   trunk/glom/mode_data/box_data_calendar_related.cc
   trunk/glom/mode_data/box_data_details.cc
   trunk/glom/mode_design/fields/box_db_table_definition.cc
   trunk/glom/mode_design/print_layouts/canvas_print_layout.cc

Modified: trunk/glom/base_db.cc
==============================================================================
--- trunk/glom/base_db.cc	(original)
+++ trunk/glom/base_db.cc	Mon Jan 26 16:52:30 2009
@@ -158,7 +158,8 @@
 }
 
 //static:
-Glib::RefPtr<Gnome::Gda::DataModel> Base_DB::query_execute_select(const Glib::ustring& strQuery, Gtk::Window* /* parent_window */)
+Glib::RefPtr<Gnome::Gda::DataModel> Base_DB::query_execute_select(const Glib::ustring& strQuery,
+                                                                  const Glib::RefPtr<Gnome::Gda::Set>& params)
 {
   Glib::RefPtr<Gnome::Gda::DataModel> result;
 
@@ -182,7 +183,8 @@
   }
 
   Glib::RefPtr<Gnome::Gda::Connection> gda_connection = sharedconnection->get_gda_connection();
-
+  Glib::RefPtr<Gnome::Gda::SqlParser> parser = gda_connection->create_parser();
+  
   const App_Glom* app = App_Glom::get_application();
   if(app && app->get_show_sql_debug())
   {
@@ -199,11 +201,27 @@
     }
 #endif
   }
-        
+  Glib::RefPtr<Gnome::Gda::Statement> stmt;
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   try
   {
-    result = gda_connection->statement_execute_select(strQuery);
+    stmt = parser->parse_string(strQuery);
+  }
+  catch(const Gnome::Gda::SqlParserError& ex)
+  {
+    std::cout << "debug: Base_DB::query_execute_select(): SqlParserError: exception from parse_string(): " << ex.what() << std::endl;
+  }
+#else
+  std::auto_ptr<Glib::Error> error;
+  stmt = parser->parse_string(strQuery, error);
+  if(error)
+     std::cout << "debug: Base_DB::query_execute_select(): SqlParserError: exception from parse_string(): " << error.what() << std::endl;
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+  
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  try
+  {
+    result = gda_connection->statement_execute_select(stmt, params);
   }
   catch(const Gnome::Gda::ConnectionError& ex)
   {
@@ -213,9 +231,14 @@
   {
     std::cout << "debug: Base_DB::query_execute_select(): ServerProviderError: exception from statement_execute_select(): " << ex.what() << std::endl;
   }
+  catch(const Glib::Error& ex)
+  {
+    std::cout << "debug: Base_DB::query_execute_select(): Error: exception from statement_execute_select(): " << ex.what() << std::endl;
+  }
+
 #else
   std::auto_ptr<Glib::Error> error;
-  result = gda_connection->statement_execute_select(strQuery, error);
+  result = gda_connection->statement_execute_select(stmt, params, error);
   if(error)
     std::cout << "debug: Base_DB::query_execute_select(): Glib::Error from statement_execute_select(): " << error->what() << std::endl;
 #endif //GLIBMM_EXCEPTIONS_ENABLED
@@ -278,7 +301,7 @@
   }
   catch(const Gnome::Gda::SqlParserError& error)
   {
-    std::cerr << "DEBUG: BaseDB::query_execute: " << error.what() << std::endl;
+    std::cerr << "DEBUG: BaseDB::query_execute: SqlParserError: " << error.what() << std::endl;
     return false;
   }
 #else
@@ -286,13 +309,11 @@
   stmt = parser->parse_string(strQuery, sql_error);
   if(sql_error)
   {
-    std::cerr << "DEBUG: BaseDB::query_execute: " << error.what() << std::endl;
+    std::cerr << "DEBUG: BaseDB::query_execute: SqlParserError:" << error.what() << std::endl;
     return false;
   }
 #endif
   int exec_retval = -1;
-  /*if (params)
-    params->reference(); // TODO: bug in libgda?*/
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   try
   {
@@ -300,7 +321,7 @@
   }
   catch(const Glib::Error& error)
   {
-    std::cerr << "BaseDB::query_execute: " << error.what() << std::endl;
+    std::cerr << "BaseDB::query_execute: ConnectionError:" << error.what() << std::endl;
     return false;
   }
 #else
@@ -308,7 +329,7 @@
   exec_retval = gda_connection->statement_execute_non_select (stmt, params, exec_error);
   if(exec_error)
   {
-    std::cerr << "BaseDB::query_execute: " << error.what() << std::endl;
+    std::cerr << "BaseDB::query_execute: ConnectionError:" << error.what() << std::endl;
     return false;
   }
 #endif
@@ -882,13 +903,19 @@
     //This should not happen:
     std::cerr << "Glom: Base_DB::auto_increment_insert_first_if_necessary(): The current user may not edit the autoincrements table. Any user who has create rights for a table should have edit rights to the autoincrements table." << std::endl;
   }
-
-
+  Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
+  Glib::RefPtr<Gnome::Gda::Holder> holder_table_name = Gnome::Gda::Holder::create(G_TYPE_STRING, "table_name");
+  Glib::RefPtr<Gnome::Gda::Holder> holder_field_name = Gnome::Gda::Holder::create(G_TYPE_STRING, "field_name");
+  holder_table_name->set_value(Gnome::Gda::Value(table_name));
+  holder_field_name->set_value(Gnome::Gda::Value(field_name));
+  params->add_holder(holder_table_name);
+  params->add_holder(holder_field_name);
+  
   const Glib::ustring sql_query = "SELECT \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME "\".\"next_value\" FROM \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME "\""
-   " WHERE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME "\" = '" + table_name + "' AND "
-          "\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME "\" = '" + field_name + "'";
+   " WHERE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME "\" = ##table_name::gchararray AND "
+          "\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME "\" = ##field_name::gchararray";
 
-  Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query);
+  Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query, params);
   if(!datamodel || (datamodel->get_n_rows() == 0))
   {
     //Start with zero:
@@ -896,9 +923,9 @@
     //Insert the row if it's not there.
     const Glib::ustring sql_query = "INSERT INTO \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME "\" ("
       GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME ", " GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME ", " GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE
-      ") VALUES ('" + table_name + "', '" + field_name + "', 0)";
+      ") VALUES (##table_name::gchararray, ##field_name::gchararray, 0)";
 
-    const bool test = query_execute(sql_query);
+    const bool test = query_execute(sql_query, params);
     if(!test)
       std::cerr << "Base_DB::auto_increment_insert_first_if_necessary(): INSERT of new row failed." << std::endl;
 
@@ -942,8 +969,8 @@
     const Glib::ustring sql_query = "UPDATE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME "\" SET "
       "\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE "\" = " + next_value.to_string() + //TODO: Don't use to_string().
       " WHERE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME "\" = '" + table_name + "' AND "
-             "\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME "\" = '" + field_name + "'";
-
+      "\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME "\" = '" + field_name + "'";
+    
     const bool test = query_execute(sql_query);
     if(!test)
       std::cerr << "Base_DB::recalculate_next_auto_increment_value(): UPDATE failed." << std::endl;
@@ -961,13 +988,21 @@
   //Increment the next_value:
   ++num_result;
   const Gnome::Gda::Value next_value = Conversions::parse_value(num_result);
-
+  Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
+  Glib::RefPtr<Gnome::Gda::Holder> holder_table_name = Gnome::Gda::Holder::create(G_TYPE_STRING, "table_name");
+  Glib::RefPtr<Gnome::Gda::Holder> holder_field_name = Gnome::Gda::Holder::create(G_TYPE_STRING, "field_name");
+  Glib::RefPtr<Gnome::Gda::Holder> holder_next_value = Gnome::Gda::Holder::create(G_TYPE_STRING, "next_value");
+  holder_table_name->set_value(Gnome::Gda::Value(table_name));
+  holder_field_name->set_value(Gnome::Gda::Value(field_name));
+  holder_next_value->set_value(next_value);
+  params->add_holder(holder_table_name);
+  params->add_holder(holder_field_name);
   const Glib::ustring sql_query = "UPDATE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME "\" SET "
-      "\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE "\" = " + next_value.to_string() +
-      " WHERE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME "\" = '" + table_name + "' AND "
-            "\""  GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME "\" = '" + field_name + "'";
+      "\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE "\" = ##next_value::gchararray"
+      " WHERE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME "\" = ##table_name::gchararray AND "
+            "\""  GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_FIELD_NAME "\" = ##field_name::gchararray";
 
-  const bool test = query_execute(sql_query);
+  const bool test = query_execute(sql_query, params);
   if(!test)
     std::cerr << "Base_DB::get_next_auto_increment_value(): Increment failed." << std::endl;
 
@@ -1058,51 +1093,42 @@
   if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
     add_standard_tables();
 
+  Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
+  params->add_holder("name", Gnome::Gda::Value(prefs.m_name));
+  params->add_holder("street", Gnome::Gda::Value(prefs.m_org_address_street));
+  params->add_holder("street2", Gnome::Gda::Value(prefs.m_org_address_street2));
+  params->add_holder("town", Gnome::Gda::Value(prefs.m_org_address_town));
+  params->add_holder("county", Gnome::Gda::Value(prefs.m_org_address_county));
+  params->add_holder("country", Gnome::Gda::Value(prefs.m_org_address_country));
+  params->add_holder("postcode", Gnome::Gda::Value(prefs.m_org_address_postcode));
+    
   //The logo field was introduced in a later version of Glom.
   //If the user is not in developer mode then the new field has not yet been added:
   Glib::ustring optional_part_logo;
   if(get_field_exists_in_database(GLOM_STANDARD_TABLE_PREFS_TABLE_NAME, GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_LOGO))
   {
-    Field field_temp_logo;
-    field_temp_logo.set_glom_type(Field::TYPE_IMAGE);
-    const Glib::ustring logo_escaped = field_temp_logo.sql(prefs.m_org_logo);
-    optional_part_logo =  "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_LOGO "\" = " + logo_escaped + ", ";
-  }
-
+    params->add_holder("org_logo", prefs.m_org_logo);
+    optional_part_logo =  "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_LOGO "\" = ##org_logo::GDA_TYPE_BINARY, ";
+  }  
   const Glib::ustring sql_query = "UPDATE \"" GLOM_STANDARD_TABLE_PREFS_TABLE_NAME "\" SET "
-      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_NAME "\" = '" + prefs.m_name + "', "
+      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_NAME "\" = ##name::gchararray, "
       + optional_part_logo +
-      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET "\" = '" + prefs.m_org_address_street + "', "
-      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET2 "\" = '" + prefs.m_org_address_street2 + "', "
-      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_TOWN "\" = '" + prefs.m_org_address_town + "', "
-      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTY "\" = '" + prefs.m_org_address_county + "', "
-      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTRY "\" = '" + prefs.m_org_address_country + "', "
-      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_POSTCODE "\" = '" + prefs.m_org_address_postcode + "'"
+      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET "\" = ##street::gchararray, "
+      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_STREET2 "\" = ##street2::gchararray, "
+      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_TOWN "\" = ##town::gchararray, "
+      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTY "\" = ##county::gchararray, "
+      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_COUNTRY "\" = ##country::gchararray, "
+      "\"" GLOM_STANDARD_TABLE_PREFS_FIELD_ORG_ADDRESS_POSTCODE "\" = ##postcode::gchararray"
       " WHERE \"" GLOM_STANDARD_TABLE_PREFS_FIELD_ID "\" = 1";
 
-    bool test = false;
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
-    try //TODO: query_execute() probably handles these already.
-#endif // GLIBMM_EXCEPTIONS_ENABLED
-    {
-      test = query_execute(sql_query);
-    }
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
-    catch(const Glib::Exception& ex)
-    {
-      std::cerr << "Base_DB::set_database_preferences(): exception: " << ex.what() << std::endl;
-    }
-    catch(const std::exception& ex)
-    {
-      std::cerr << "Base_DB::set_database_preferences(): exception: " << ex.what() << std::endl;
-    }
-#endif // GLIBMM_EXCEPTIONS_ENABLED
-
-    if(!test)
-      std::cerr << "Base_DB::set_database_preferences(): UPDATE failed." << std::endl;
+  bool test = false;
+  test = query_execute(sql_query, params);
 
-    //Set some information in the document too, so we can use it to recreate the database:
-    get_document()->set_database_title(prefs.m_name);
+  if(!test)
+    std::cerr << "Base_DB::set_database_preferences(): UPDATE failed." << std::endl;
+  
+  //Set some information in the document too, so we can use it to recreate the database:
+  get_document()->set_database_title(prefs.m_name);
 }
 
 bool Base_DB::create_table_with_default_fields(const Glib::ustring& table_name)
@@ -2392,10 +2418,12 @@
   const Glib::ustring field_name = field_in_record.m_field->get_name();
   if(!field_name.empty()) //This should not happen.
   {
-   
+    Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
+    params->add_holder(field_in_record.m_field->get_holder());
+    params->add_holder(field_in_record.m_key->get_holder());  
     Glib::ustring strQuery = "UPDATE \"" + field_in_record.m_table_name + "\"";
-    strQuery += " SET \"" + field_in_record.m_field->get_name() + "\" = " + field_in_record.m_field->sql(field_value);
-    strQuery += " WHERE \"" + field_in_record.m_key->get_name() + "\" = " + field_in_record.m_key->sql(field_in_record.m_key_value);
+    strQuery += " SET \"" + field_in_record.m_field->get_name() + "\" = " + field_in_record.m_field->get_gda_holder_string();
+    strQuery += " WHERE \"" + field_in_record.m_key->get_name() + "\" = " + field_in_record.m_key->get_gda_holder_string();
 
     //std::cout << "debug: set_field_value_in_database(): " << std::endl << "  " << strQuery << std::endl;
 
@@ -2403,7 +2431,7 @@
     try //TODO: The exceptions are probably already handled by query_execute(0.
 #endif
     {
-      const bool test = query_execute(strQuery); //TODO: Respond to failure.
+      const bool test = query_execute(strQuery, params); //TODO: Respond to failure.
       if(!test)
       {
         std::cerr << "Box_Data::set_field_value_in_database(): UPDATE failed." << std::endl;

Modified: trunk/glom/base_db.h
==============================================================================
--- trunk/glom/base_db.h	(original)
+++ trunk/glom/base_db.h	Mon Jan 26 16:52:30 2009
@@ -81,7 +81,8 @@
   /** Execute a SQL Select command, returning the result.
    * This method handles any Gda exceptions caused by executing the command.
    */
-  static Glib::RefPtr<Gnome::Gda::DataModel> query_execute_select(const Glib::ustring& strQuery, Gtk::Window* parent_window = 0);
+  static Glib::RefPtr<Gnome::Gda::DataModel> query_execute_select(const Glib::ustring& strQuery, 
+                                                                  const Glib::RefPtr<Gnome::Gda::Set>& params = Glib::RefPtr<Gnome::Gda::Set>(0));
 
 
   /** Execute a SQL non-select command, returning true if it succeeded.

Modified: trunk/glom/base_db_table_data.cc
==============================================================================
--- trunk/glom/base_db_table_data.cc	(original)
+++ trunk/glom/base_db_table_data.cc	Mon Jan 26 16:52:30 2009
@@ -261,7 +261,7 @@
 
   //TODO_Performance: Is this the best way to just find out whether there is one record that meets this criteria?
   const Glib::ustring query = "SELECT \"" + to_field + "\" FROM \"" + relationship->get_to_table() + "\" WHERE \"" + related_table + "\".\"" + to_field + "\" = " + key_field->sql(key_value);
-  Glib::RefPtr<Gnome::Gda::DataModel> records = query_execute_select(query, App_Glom::get_application());
+  Glib::RefPtr<Gnome::Gda::DataModel> records = query_execute_select(query);
   if(!records)
     handle_error();
   else

Modified: trunk/glom/dialog_database_preferences.cc
==============================================================================
--- trunk/glom/dialog_database_preferences.cc	(original)
+++ trunk/glom/dialog_database_preferences.cc	Mon Jan 26 16:52:30 2009
@@ -141,7 +141,7 @@
 
   NumericFormat numeric_format; //ignored
 
-  Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query, this);
+  Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query);
   if(!datamodel)
   {
     std::cerr << "Dialog_Database_Preferences::load_from_document(): Gda::DataModel is NULL." << std::endl;

Modified: trunk/glom/frame_glom.cc
==============================================================================
--- trunk/glom/frame_glom.cc	(original)
+++ trunk/glom/frame_glom.cc	Mon Jan 26 16:52:30 2009
@@ -593,7 +593,7 @@
   const Glib::ustring query = Utils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, found_set.m_where_clause, found_set.m_extra_join, found_set.m_sort_clause, found_set.m_extra_group_by);
 
   //TODO: Lock the database (prevent changes) during export.
-  Glib::RefPtr<Gnome::Gda::DataModel> result = query_execute_select(query, get_app_window());
+  Glib::RefPtr<Gnome::Gda::DataModel> result = query_execute_select(query);
 
   guint rows_count = 0;
   if(result)
@@ -645,7 +645,7 @@
   const Glib::ustring query = Utils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, found_set.m_where_clause, found_set.m_extra_join, found_set.m_sort_clause, found_set.m_extra_group_by);
  
   //TODO: Lock the database (prevent changes) during export.
-  Glib::RefPtr<Gnome::Gda::DataModel> result = query_execute_select(query, get_app_window());
+  Glib::RefPtr<Gnome::Gda::DataModel> result = query_execute_select(query);
 
   guint rows_count = 0;
   if(result)

Modified: trunk/glom/libglom/data_structure/field.cc
==============================================================================
--- trunk/glom/libglom/data_structure/field.cc	(original)
+++ trunk/glom/libglom/data_structure/field.cc	Mon Jan 26 16:52:30 2009
@@ -745,6 +745,20 @@
   return g_type_name(get_gda_g_type());
 }
 
+Glib::RefPtr<Gnome::Gda::Holder> Field::get_holder(const Glib::ustring& name) const
+{
+  Glib::ustring real_name = name.empty() ? get_name() : name;
+  Glib::RefPtr<Gnome::Gda::Holder> holder = Gnome::Gda::Holder::create(get_gda_g_type(),
+                                                                       real_name);
+  holder->set_value(get_data());
+  return holder;
+}
+Glib::ustring Field::get_gda_holder_string(const Glib::ustring& name) const
+{
+  Glib::ustring real_name = name.empty() ? get_name() : name;
+  return "##" + real_name + "::" + get_gda_type();
+}
+
 /// Ignores any part of FieldAttributes that libgda does not properly fill.
 bool Field::field_info_from_database_is_equal(const Glib::RefPtr<const Gnome::Gda::Column>& field)
 {

Modified: trunk/glom/libglom/data_structure/field.h
==============================================================================
--- trunk/glom/libglom/data_structure/field.h	(original)
+++ trunk/glom/libglom/data_structure/field.h	Mon Jan 26 16:52:30 2009
@@ -161,6 +161,8 @@
   Glib::ustring get_sql_type() const;
   Glib::ustring get_gda_type() const;
   GType get_gda_g_type() const;
+  Glib::RefPtr<Gnome::Gda::Holder> get_holder(const Glib::ustring& name = Glib::ustring()) const;
+  Glib::ustring get_gda_holder_string(const Glib::ustring& name = Glib::ustring()) const;
 
   /** Escape the value so that it can be used in a SQL command.
    */

Modified: trunk/glom/mode_data/box_data.cc
==============================================================================
--- trunk/glom/mode_data/box_data.cc	(original)
+++ trunk/glom/mode_data/box_data.cc	Mon Jan 26 16:52:30 2009
@@ -294,7 +294,7 @@
   {
     const Glib::ustring query = Utils::build_sql_select_with_key(field_in_record_changed.m_table_name, fieldsToGet, field_in_record_changed.m_key, field_in_record_changed.m_key_value);
 
-    Glib::RefPtr<Gnome::Gda::DataModel> result = query_execute_select(query, get_app_window());
+    Glib::RefPtr<Gnome::Gda::DataModel> result = query_execute_select(query);
     if(!result)
     {
       g_warning("Box_Data_List::refresh_related_fields(): no result.");

Modified: trunk/glom/mode_data/box_data_calendar_related.cc
==============================================================================
--- trunk/glom/mode_data/box_data_calendar_related.cc	(original)
+++ trunk/glom/mode_data/box_data_calendar_related.cc	Mon Jan 26 16:52:30 2009
@@ -185,7 +185,7 @@
     
     const Glib::ustring sql_query = Utils::build_sql_select_with_where_clause(m_found_set.m_table_name, m_FieldsShown, where_clause, m_found_set.m_extra_join, m_found_set.m_sort_clause, m_found_set.m_extra_group_by);
     //std::cout << "DEBUG: sql_query=" << sql_query << std::endl;
-    Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query, get_app_window());
+    Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query);
     if(!(datamodel))
       return true;
     

Modified: trunk/glom/mode_data/box_data_details.cc
==============================================================================
--- trunk/glom/mode_data/box_data_details.cc	(original)
+++ trunk/glom/mode_data/box_data_details.cc	Mon Jan 26 16:52:30 2009
@@ -333,7 +333,7 @@
         Glib::RefPtr<Gnome::Gda::DataModel> result;
 
         if(!primary_key_is_empty)
-          result = query_execute_select(query, get_app_window());
+          result = query_execute_select(query);
 
         if((result && result->get_n_rows()) || primary_key_is_empty) //either a working result or no result needed.
         {

Modified: trunk/glom/mode_design/fields/box_db_table_definition.cc
==============================================================================
--- trunk/glom/mode_design/fields/box_db_table_definition.cc	(original)
+++ trunk/glom/mode_design/fields/box_db_table_definition.cc	Mon Jan 26 16:52:30 2009
@@ -608,7 +608,7 @@
   //std::cout << "sql_query: " << sql_query << std::endl;
 
   long null_count = 0;
-  Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query, get_app_window());
+  Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query);
   if(datamodel && datamodel->get_n_rows() && datamodel->get_n_columns())
   {
     null_count = datamodel->get_n_rows();
@@ -630,7 +630,7 @@
   //Count the distint rows:
   const Glib::ustring sql_query_distinct = "SELECT DISTINCT \"" + field->get_name() + "\" FROM \"" + m_table_name + "\"";
   
-  Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query_distinct, get_app_window());
+  Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query_distinct);
   if(datamodel)
   {
     count_distinct = datamodel->get_n_rows();
@@ -644,7 +644,7 @@
   //Count all rows, to compare. TODO_performance: Is there a more efficient way to do this? Maybe count(*), which apparently doesn't ignore NULL rows like count(somefield) would.
   const Glib::ustring sql_query_all = "SELECT \"" + field->get_name() + "\" FROM \"" + m_table_name + "\"";
   
-  datamodel = query_execute_select(sql_query_all, get_app_window());
+  datamodel = query_execute_select(sql_query_all);
   if(datamodel)
   {
     count_all = datamodel->get_n_rows();

Modified: trunk/glom/mode_design/print_layouts/canvas_print_layout.cc
==============================================================================
--- trunk/glom/mode_design/print_layouts/canvas_print_layout.cc	(original)
+++ trunk/glom/mode_design/print_layouts/canvas_print_layout.cc	Mon Jan 26 16:52:30 2009
@@ -686,7 +686,7 @@
 
   const Glib::ustring sql_query = Utils::build_sql_select_with_where_clause(found_set.m_table_name, fields_shown, found_set.m_where_clause, found_set.m_extra_join, found_set.m_sort_clause, found_set.m_extra_group_by);
   //std::cout << "DEBUG: sql_query=" << sql_query << std::endl;
-  Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query, 0 /* TODO: get_app_window() */);
+  Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute_select(sql_query);
   if(!(datamodel))
     return;
     



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