glom r1532 - in trunk: . glom/libglom glom/mode_design/fields



Author: murrayc
Date: Mon Apr  7 17:32:51 2008
New Revision: 1532
URL: http://svn.gnome.org/viewvc/glom?rev=1532&view=rev

Log:
2008-04-07  Murray Cumming  <murrayc murrayc com>

* glom/mode_design/fields/box_db_table_definition.cc
  check_field_change(): Refuse to change a field name to one that 
already exists.

Modified:
   trunk/ChangeLog
   trunk/glom/libglom/connectionpool.cc
   trunk/glom/mode_design/fields/box_db_table_definition.cc

Modified: trunk/glom/libglom/connectionpool.cc
==============================================================================
--- trunk/glom/libglom/connectionpool.cc	(original)
+++ trunk/glom/libglom/connectionpool.cc	Mon Apr  7 17:32:51 2008
@@ -211,6 +211,7 @@
 
 ConnectionPool::~ConnectionPool()
 {
+  std::cout << "~ConnectionPool(): m_refGdaConnection refcount=" << G_OBJECT(m_refGdaConnection->gobj())->ref_count << std::endl;
   if(m_pFieldTypes)
   {
     delete m_pFieldTypes;
@@ -371,7 +372,7 @@
             if(glib_error.get())
               break;
 #endif
-            //std::cout << "m_refGdaConnection refcount=" << G_OBJECT(m_refGdaConnection->gobj())->ref_count << std::endl;
+            std::cout << "m_refGdaConnection refcount=" << G_OBJECT(m_refGdaConnection->gobj())->ref_count << std::endl;
 
             //g_warning("ConnectionPool: connection opened");
 

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 Apr  7 17:32:51 2008
@@ -252,30 +252,44 @@
 
     dialog.run();
 
-    result = false;
+    return false;
   }
-  else
+
+  //Refuse to set a second primary key:
+  //bool bcontinue = true;
+  if(field_new->get_primary_key() && !field_old->get_primary_key()) //Was the primary key column checked?
   {
-    //Refuse to set a second primary key:
-    //bool bcontinue = true;
-    if(field_new->get_primary_key() && !field_old->get_primary_key()) //Was the primary key column checked?
-    {
-      //Is there an existing primary key?
-      sharedptr<Field> existing_primary_key = get_field_primary_key_for_table(m_table_name);
-      if(existing_primary_key)
-      {
-        //Warn the user and refuse to make the change:
-        Gtk::MessageDialog dialog(Bakery::App_Gtk::util_bold_message(_("Too many primary keys")), true);
-        dialog.set_secondary_text(_("You may not specify more than one field as the primary key."));
-        if(parent_window)
-          dialog.set_transient_for(*parent_window);
-        dialog.run();
+    //Is there an existing primary key?
+    sharedptr<Field> existing_primary_key = get_field_primary_key_for_table(m_table_name);
+    if(existing_primary_key)
+    {
+      //Warn the user and refuse to make the change:
+      Gtk::MessageDialog dialog(Bakery::App_Gtk::util_bold_message(_("Too many primary keys")), true);
+      dialog.set_secondary_text(_("You may not specify more than one field as the primary key."));
+      if(parent_window)
+        dialog.set_transient_for(*parent_window);
+      dialog.run();
 
-        result = false;
-      }
+      return false;
     }
   }
 
+  //Refuse to change a field name to the same as an existing one:
+  if( (field_new->get_name() != field_old->get_name()) &&
+      (get_field_exists_in_database(m_table_name, field_new->get_name())) )
+  {
+    std::cout << "get_field_exists_in_database(" << m_table_name << ", " << field_new->get_name() << ") returned true" << std::endl;
+
+    //Warn the user and refuse to make the change:
+    Gtk::MessageDialog dialog(Bakery::App_Gtk::util_bold_message(_("Field Name Already Exists")), true);
+    dialog.set_secondary_text(_("This field already exists. Please choose a different field name"));
+    if(parent_window)
+      dialog.set_transient_for(*parent_window);
+    dialog.run();
+
+    return false;
+  }
+
   return result;
 }
 



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