glom r1875 - in trunk: . glom glom/libglom/data_structure glom/libglom/document glom/navigation



Author: murrayc
Date: Tue Feb  3 17:12:08 2009
New Revision: 1875
URL: http://svn.gnome.org/viewvc/glom?rev=1875&view=rev

Log:
2009-02-03  Murray Cumming  <murrayc murrayc com>

* glom/base_db.cc: get_table_names_from_database(): Filter out some 
extra internal table names which may be created/reported by newer 
versions of libgda.

Modified:
   trunk/ChangeLog
   trunk/glom/base_db.cc
   trunk/glom/glom_privs.cc
   trunk/glom/libglom/data_structure/field.h
   trunk/glom/libglom/document/document_glom.cc
   trunk/glom/navigation/box_tables.cc

Modified: trunk/glom/base_db.cc
==============================================================================
--- trunk/glom/base_db.cc	(original)
+++ trunk/glom/base_db.cc	Tue Feb  3 17:12:08 2009
@@ -412,23 +412,28 @@
           table_name = value.get_string();
           //std::cout << "DEBUG: Found table: " << table_name << std::endl;
 
-          bool add_it = true;
-
           if(ignore_system_tables)
           {
             //Check whether it's a system table:
             const Glib::ustring prefix = "glom_system_";
             const Glib::ustring table_prefix = table_name.substr(0, prefix.size());
             if(table_prefix == prefix)
-              add_it = false;
+              continue;
           }
 
           //Ignore the pga_* tables that pgadmin adds when you use it:
           if(table_name.substr(0, 4) == "pga_")
-            add_it = false;
+            continue;
+
+          //Ignore the pg_* tables that something (Postgres? libgda?) adds:
+          if(table_name.substr(0, 14) == "pg_catalog.pg_")
+            continue;
+
+          //Ignore the information_schema tables that something (libgda?) adds:
+          if(table_name.substr(0, 23) == "information_schema.sql_")
+            continue;
 
-          if(add_it)
-            result.push_back(table_name);
+          result.push_back(table_name);
         }
       }
     }

Modified: trunk/glom/glom_privs.cc
==============================================================================
--- trunk/glom/glom_privs.cc	(original)
+++ trunk/glom/glom_privs.cc	Tue Feb  3 17:12:08 2009
@@ -29,7 +29,7 @@
 {
   type_vecStrings result;
 
-  Glib::ustring strQuery = "SELECT \"pg_group\".\"groname\" FROM \"pg_group\"";
+  const Glib::ustring strQuery = "SELECT \"pg_group\".\"groname\" FROM \"pg_group\"";
   Glib::RefPtr<Gnome::Gda::DataModel> data_model = query_execute_select(strQuery);
   if(data_model)
   {
@@ -54,7 +54,7 @@
   if(group_name.empty())
   {
     //pg_shadow contains the users. pg_users is a view of pg_shadow without the password.
-    Glib::ustring strQuery = "SELECT \"pg_shadow\".\"usename\" FROM \"pg_shadow\"";
+    const Glib::ustring strQuery = "SELECT \"pg_shadow\".\"usename\" FROM \"pg_shadow\"";
     Glib::RefPtr<Gnome::Gda::DataModel> data_model = query_execute_select(strQuery);
     if(data_model)
     {
@@ -69,7 +69,7 @@
   }
   else
   {
-    Glib::ustring strQuery = "SELECT \"pg_group\".\"groname\", \"pg_group\".\"grolist\" FROM \"pg_group\" WHERE \"pg_group\".\"groname\" = '" + group_name + "'";
+    const Glib::ustring strQuery = "SELECT \"pg_group\".\"groname\", \"pg_group\".\"grolist\" FROM \"pg_group\" WHERE \"pg_group\".\"groname\" = '" + group_name + "'";
     Glib::RefPtr<Gnome::Gda::DataModel> data_model = query_execute_select(strQuery);
     if(data_model && data_model->get_n_rows())
     {
@@ -87,7 +87,7 @@
         for(type_vecStrings::const_iterator iter = vecUserIds.begin(); iter != vecUserIds.end(); ++iter)
         {
           //TODO_Performance: Can we do this in one SQL SELECT?
-          Glib::ustring strQuery = "SELECT \"pg_user\".\"usename\" FROM \"pg_user\" WHERE \"pg_user\".\"usesysid\" = '" + *iter + "'";
+          const Glib::ustring strQuery = "SELECT \"pg_user\".\"usename\" FROM \"pg_user\" WHERE \"pg_user\".\"usesysid\" = '" + *iter + "'";
           Glib::RefPtr<Gnome::Gda::DataModel> data_model = query_execute_select(strQuery);
           if(data_model)
           {

Modified: trunk/glom/libglom/data_structure/field.h
==============================================================================
--- trunk/glom/libglom/data_structure/field.h	(original)
+++ trunk/glom/libglom/data_structure/field.h	Tue Feb  3 17:12:08 2009
@@ -162,12 +162,11 @@
   Glib::ustring get_gda_type() const;
   GType get_gda_g_type() const;
 
-  /** TODO: Documentation.
-   */
+  /// A convenience when using parameters with a libgda SQL query.
   Glib::RefPtr<Gnome::Gda::Holder> get_holder(const Glib::ustring& name = Glib::ustring()) const;
-
-  /** TODO: Documentation.
-   */
+ 
+  //TODO: Shouldn't this be called get_gda_holder_name()?
+  /// A convenience when using parameters with a libgda SQL query.
   Glib::RefPtr<Gnome::Gda::Holder> get_holder(const Gnome::Gda::Value& value, const Glib::ustring& name = Glib::ustring()) const;
 
   /** TODO: Documentation.

Modified: trunk/glom/libglom/document/document_glom.cc
==============================================================================
--- trunk/glom/libglom/document/document_glom.cc	(original)
+++ trunk/glom/libglom/document/document_glom.cc	Tue Feb  3 17:12:08 2009
@@ -197,7 +197,7 @@
 #define GLOM_ATTRIBUTE_POSITION_WIDTH "width"
 #define GLOM_ATTRIBUTE_POSITION_HEIGHT "height"
 
-#define GLOM_NODE_PAGE_SETUP "page_setup" //It's text child is the keyfile for a GtkPageSetup
+#define GLOM_NODE_PAGE_SETUP "page_setup" //Its text child is the keyfile for a GtkPageSetup
 
 #define GLOM_NODE_LIBRARY_MODULES "library_modules"
 #define GLOM_NODE_LIBRARY_MODULE "module"

Modified: trunk/glom/navigation/box_tables.cc
==============================================================================
--- trunk/glom/navigation/box_tables.cc	(original)
+++ trunk/glom/navigation/box_tables.cc	Tue Feb  3 17:12:08 2009
@@ -144,23 +144,24 @@
 #else
   std::auto_ptr<ExceptionConnection> error;
   sharedptr<SharedConnection> sharedconnection = connect_to_server(App_Glom::get_application(), error);
-  // Ignore error, sharedconnection presence is checked below
+  // Ignore error because sharedconnection presence is checked below.
 #endif
+
   if(sharedconnection)
   {
     m_AddDel.remove_all();
     Glib::RefPtr<Gnome::Gda::Connection> connection = sharedconnection->get_gda_connection();
 
-    type_vecStrings vecTables = get_table_names_from_database();
+    const type_vecStrings vecTables = get_table_names_from_database();
 
-    for(type_vecStrings::iterator iter = vecTables.begin(); iter != vecTables.end(); iter++)
+    for(type_vecStrings::const_iterator iter = vecTables.begin(); iter != vecTables.end(); iter++)
     {
       const Glib::ustring strName = *iter;
 
       sharedptr<TableInfo> table_info;
 
       //Check whether it should be hidden:
-      Document_Glom::type_listTableInfo::iterator iterFind = std::find_if(listTablesDocument.begin(), listTablesDocument.end(), predicate_FieldHasName<TableInfo>(strName));
+      Document_Glom::type_listTableInfo::const_iterator iterFind = std::find_if(listTablesDocument.begin(), listTablesDocument.end(), predicate_FieldHasName<TableInfo>(strName));
       if(iterFind != listTablesDocument.end())
       {
         table_info = *iterFind;
@@ -179,7 +180,7 @@
       const bool hidden = table_info->m_hidden;
 
       bool bAddIt = true;
-      if(hidden && !developer_mode)  //Don't add hidden tables unless we are in developer mode:
+      if(hidden && !developer_mode) //Don't add hidden tables unless we are in developer mode:
         bAddIt = false;
 
       if(hidden && !m_pCheckButtonShowHidden->get_active()) //Don't add hidden tables if that checkbox is unset.
@@ -191,9 +192,7 @@
       const Glib::ustring prefix = "glom_system_";
       const Glib::ustring table_prefix = strName.substr(0, prefix.size());
       if(table_prefix == prefix)
-      {
         bAddIt = false;
-      }
 
       if(bAddIt)
       {



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