[glom/glom-1-20] test_fake_connection: Avoid unnecessary warnings about metadata.



commit 5c3f781176bb34ead046d4b65336f6a65741b4f4
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Dec 8 21:36:39 2011 +0100

    test_fake_connection: Avoid unnecessary warnings about metadata.
    
    	* glom/libglom/connectionpool.cc: Avoid printing exceptions to stderr
    	about failed attempts to get types and tables metadata, because
    	this is not used by fake connections, for instance by java-libglom.
    	There will be a warning later if it is really used.
    	* glom/libglom/db_utils.cc: Add some comments.

 ChangeLog                      |   10 ++++++++++
 glom/libglom/connectionpool.cc |   24 +++++++++++++++++++++---
 glom/libglom/db_utils.cc       |    3 +++
 3 files changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 48e95e3..d7d413a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-12-08  Murray Cumming  <murrayc murrayc com>
+
+	test_fake_connection: Avoid unnecessary warnings about metadata.
+
+	* glom/libglom/connectionpool.cc: Avoid printing exceptions to stderr
+	about failed attempts to get types and tables metadata, because 
+	this is not used by fake connections, for instance by java-libglom.
+	There will be a warning later if it is really used.
+	* glom/libglom/db_utils.cc: Add some comments.
+
 2011-12-06  Murray Cumming  <murrayc murrayc com>
 
 	Use EXIT_* instead of 0 and -1.
diff --git a/glom/libglom/connectionpool.cc b/glom/libglom/connectionpool.cc
index c11fe8f..3cf8354 100644
--- a/glom/libglom/connectionpool.cc
+++ b/glom/libglom/connectionpool.cc
@@ -324,7 +324,13 @@ sharedptr<SharedConnection> ConnectionPool::connect()
         }
         catch(const Glib::Error& ex)
         {
-          std::cerr << G_STRFUNC << ": update_meta_store_data_types() failed: " << ex.what() << std::endl;
+          //If the conneciton was not opened, because it is a fake connection,
+          //then we should not be surprised that this fails,
+          //and a warning will only be useful later when get_meta_store_data() fails when used in FieldTypes, from Field::set_*().
+          if(!m_fake_connection)
+          {
+            std::cerr << G_STRFUNC << ": update_meta_store_data_types() failed: " << ex.what() << std::endl;
+          }
         }
         //std::cout << "DEBUG: ... update_meta_store_data_types() has finished." << std::endl;
 
@@ -338,7 +344,13 @@ sharedptr<SharedConnection> ConnectionPool::connect()
         }
         catch(const Glib::Error& ex)
         {
-          std::cerr << G_STRFUNC << ": update_meta_store_table_names() failed: " << ex.what() << std::endl;
+          //If the conneciton was not opened, because it is a fake connection,
+          //then we should not be surprised that this fails,
+          //and a warning will only be useful later when get_meta_store_data() fails when used in get_table_names_from_database().
+          if(!m_fake_connection)
+          {
+            std::cerr << G_STRFUNC << ": update_meta_store_table_names() failed: " << ex.what() << std::endl;
+          }
         }
         //std::cout << "DEBUG: ... update_meta_store_table_names() has finished." << std::endl;
 
@@ -439,7 +451,13 @@ bool ConnectionPool::convert_backup(const SlotProgress& slot_progress, const std
   }
   catch(const Glib::Error& ex)
   {
-    std::cerr << "ConnectionPool::connect(): update_meta_store_table_names() failed: " << ex.what() << std::endl;
+    //If the conneciton was not opened, because it is a fake connection,
+    //then we should not be surprised that this fails,
+    //and a warning will only be useful later when get_meta_store_data() fails when used in get_table_names_from_database().
+    if(!m_fake_connection)
+    {
+      std::cerr << "ConnectionPool::connect(): update_meta_store_table_names() failed: " << ex.what() << std::endl;
+    }
   }
 
   return result;
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index 0c2a639..c044af9 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -841,6 +841,8 @@ type_vec_fields get_fields_for_table_from_database(const Glib::ustring& table_na
     Glib::RefPtr<Gnome::Gda::DataModel> data_model_fields;
     try
     {
+      //This should work because we called update_meta_store_tables() in ConnectionPool,
+      //and that gets the tables' fields too.
       data_model_fields = connection->get_meta_store_data(Gnome::Gda::CONNECTION_META_FIELDS, holder_list);
     }
     catch(const Gnome::Gda::MetaStoreError& ex)
@@ -970,6 +972,7 @@ type_vec_strings get_table_names_from_database(bool ignore_system_tables)
     Glib::RefPtr<Gnome::Gda::DataModel> data_model_tables;
     try
     {
+      //This should work because we called update_meta_store_tables() in ConnectionPool.
       data_model_tables = gda_connection->get_meta_store_data(Gnome::Gda::CONNECTION_META_TABLES);
     }
     catch(const Gnome::Gda::MetaStoreError& ex)



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