[glom/mysql] MySQL: Do not try to insert image examples.



commit 09f06f8da4c041b3efba223d8f0c3dea298a6ba5
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Jan 5 15:01:41 2013 +0100

    MySQL: Do not try to insert image examples.

 glom/libglom/db_utils.cc                           |   15 ++++++++++++++-
 .../test_selfhosting_new_from_example_operator.cc  |    7 +++++++
 2 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index 12280a9..83c45f4 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -1585,7 +1585,7 @@ bool insert_example_data(Document* document, const Glib::ustring& table_name)
 
 
   //Get field names:
-  Document::type_vec_fields vec_fields = document->get_table_fields(table_name);
+  const Document::type_vec_fields vec_fields = document->get_table_fields(table_name);
 
   //Actually insert the data:
   //std::cout << "debug: " << G_STRFUNC << ": number of rows of data: " << vec_rows.size() << std::endl;
@@ -1603,6 +1603,8 @@ bool insert_example_data(Document* document, const Glib::ustring& table_name)
 
     //std::cout << "DEBUG: row_data size = " << row_data.size() << ", (fields size= " << vec_fields.size() << " )" << std::endl;
 
+    const Document::HostingMode hosting_mode = document->get_hosting_mode();
+
     Glib::RefPtr<Gnome::Gda::SqlBuilder> builder = Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_INSERT);
     builder->set_table(table_name);
     for(unsigned int i = 0; i < row_data.size(); ++i) //TODO_Performance: Avoid calling size() so much.
@@ -1616,6 +1618,17 @@ bool insert_example_data(Document* document, const Glib::ustring& table_name)
         break;
       }
 
+      if(field->get_glom_type() == Field::TYPE_IMAGE)
+      {
+        if((hosting_mode == Document::HOSTING_MODE_MYSQL_CENTRAL) ||
+          (hosting_mode == Document::HOSTING_MODE_MYSQL_SELF))
+        {
+          //TODO: See https://bugzilla.gnome.org/show_bug.cgi?id=691099
+          std::cerr << G_STRFUNC << ": Skipping Image field because libgda does not support it for MySQL." << std::endl;
+          break;
+        }
+      }
+
       builder->add_field_value(field->get_name(), row_data[i]);
     }
 
diff --git a/tests/test_selfhosting_new_from_example_operator.cc b/tests/test_selfhosting_new_from_example_operator.cc
index c603fc5..d68114f 100644
--- a/tests/test_selfhosting_new_from_example_operator.cc
+++ b/tests/test_selfhosting_new_from_example_operator.cc
@@ -68,6 +68,13 @@ static bool test(Glom::Document::HostingMode hosting_mode)
       return false;
     }
 
+    //TODO_MySQL: Implement groups/users code.
+    if(hosting_mode == Glom::Document::HOSTING_MODE_MYSQL_SELF)
+    {
+      test_selfhosting_cleanup(false /* do not delete the file. */);
+      return true;
+    }
+
     //Add an operator user:
     const Glib::ustring operator_group_name = "personnel_department";
     const Glom::DbUtils::type_vec_strings group_list = 



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