SVN Commit by dpage: r4459 - in trunk/pgadmin3/src: dlg schema - Mailing list pgadmin-hackers

From svn@pgadmin.org
Subject SVN Commit by dpage: r4459 - in trunk/pgadmin3/src: dlg schema
Date
Msg-id 200509230856.j8N8urKR005096@developer.pgadmin.org
Whole thread Raw
List pgadmin-hackers
Author: dpage
Date: 2005-09-23 09:56:53 +0100 (Fri, 23 Sep 2005)
New Revision: 4459

Modified:
   trunk/pgadmin3/src/dlg/dlgTable.cpp
   trunk/pgadmin3/src/schema/pgForeignKey.cpp
Log:
Fix ordering of table modification SQL per report from Diego Gil.

Modified: trunk/pgadmin3/src/dlg/dlgTable.cpp
===================================================================
--- trunk/pgadmin3/src/dlg/dlgTable.cpp    2005-09-23 07:47:01 UTC (rev 4458)
+++ trunk/pgadmin3/src/dlg/dlgTable.cpp    2005-09-23 08:56:53 UTC (rev 4459)
@@ -211,6 +211,7 @@
                         lstConstraints->AppendItem(data->GetIconId(), obj->GetName(), obj->GetDefinition());
                         previousConstraints.Add(obj->GetQuotedIdentifier()
                             + wxT(" ") + obj->GetTypeName().Upper() + wxT(" ") + obj->GetDefinition());
+                        break;
                     }
                     case PGM_FOREIGNKEY:
                     {
@@ -310,8 +311,14 @@
         int index=-1;

         wxString definition;
+
+        AppendNameChange(sql);
+        AppendOwnerChange(sql, wxT("TABLE ") + tabname);
+
         wxArrayString tmpDef=previousColumns;
+        wxString tmpsql;

+        // Build a tmeporary list of ADD COLUMNs, and fixup the list to remove
         for (pos=0; pos < lstColumns->GetItemCount() ; pos++)
         {
             definition = lstColumns->GetText(pos, 3);
@@ -320,12 +327,12 @@
                 definition=qtIdent(lstColumns->GetText(pos)) + wxT(" ") + lstColumns->GetText(pos, 1);
                 index=tmpDef.Index(definition);
                 if (index < 0)
-                    sql += wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
+                    tmpsql += wxT("ALTER TABLE ") + tabname
                         +  wxT(" ADD COLUMN ") + definition + wxT(";\n");
             }
             else
             {
-                sql += definition;
+                tmpsql += definition;

                 pgColumn *column=(pgColumn*) StrToLong(lstColumns->GetText(pos, 6));
                 if (column)
@@ -338,8 +345,6 @@
                 tmpDef.RemoveAt(index);
         }

-        AppendNameChange(sql);
-        AppendOwnerChange(sql, wxT("TABLE ") + tabname);

         for (index=0 ; index < (int)tmpDef.GetCount() ; index++)
         {
@@ -351,11 +356,13 @@
             sql += wxT("ALTER TABLE ") + tabname
                 +  wxT(" DROP COLUMN ") + qtIdent(definition) + wxT(";\n");
         }
+        // Add the ADD COLUMNs...
+        sql += tmpsql;

-
-
         tmpDef=previousConstraints;
+        tmpsql.Empty();

+        // Build a tmeporary list of ADD CONSTRAINTs, and fixup the list to remove
         for (pos=0; pos < lstConstraints->GetItemCount() ; pos++)
         {
             wxString conname= qtIdent(lstConstraints->GetItemText(pos));
@@ -367,12 +374,12 @@
                 tmpDef.RemoveAt(index);
             else
             {
-                sql += wxT("ALTER TABLE ") + tabname
+                tmpsql += wxT("ALTER TABLE ") + tabname
                     +  wxT(" ADD");
                 if (!conname.IsEmpty())
                     sql += wxT(" CONSTRAINT ");

-                sql += definition + wxT(";\n");
+                tmpsql += definition + wxT(";\n");
             }
         }

@@ -386,6 +393,9 @@
             sql += wxT("ALTER TABLE ") + tabname
                 +  wxT(" DROP CONSTRAINT ") + qtIdent(definition) + wxT(";\n");
         }
+        // Add the ADD CONSTRAINTs...
+        sql += tmpsql;
+
         if (chkHasOids->GetValue() != table->GetHasOids())
         {
             sql += wxT("ALTER TABLE ") + tabname

Modified: trunk/pgadmin3/src/schema/pgForeignKey.cpp
===================================================================
--- trunk/pgadmin3/src/schema/pgForeignKey.cpp    2005-09-23 07:47:01 UTC (rev 4458)
+++ trunk/pgadmin3/src/schema/pgForeignKey.cpp    2005-09-23 08:56:53 UTC (rev 4459)
@@ -268,7 +268,7 @@


 pgForeignKeyFactory::pgForeignKeyFactory()
-: pgTableObjFactory(__("foreignKey"), __("New Foreign Key"), __("Create a new Foreign Key."), foreignkey_xpm)
+: pgTableObjFactory(__("foreign Key"), __("New Foreign Key"), __("Create a new Foreign Key."), foreignkey_xpm)
 {
     metaType = PGM_FOREIGNKEY;
     collectionFactory = &constraintCollectionFactory;


pgadmin-hackers by date:

Previous
From: svn@pgadmin.org
Date:
Subject: SVN Commit by dpage: r4458 - in trunk/pgadmin3/src: agent dlg
Next
From: Miha Radej
Date:
Subject: altering table properties