SVN Commit by andreas: r4858 - branches/REL-1_4_0_PATCHES/pgadmin3/src/frm - Mailing list pgadmin-hackers

From svn@pgadmin.org
Subject SVN Commit by andreas: r4858 - branches/REL-1_4_0_PATCHES/pgadmin3/src/frm
Date
Msg-id 200512261445.jBQEjZE9017413@developer.pgadmin.org
Whole thread Raw
List pgadmin-hackers
Author: andreas
Date: 2005-12-26 14:45:34 +0000 (Mon, 26 Dec 2005)
New Revision: 4858

Modified:
   branches/REL-1_4_0_PATCHES/pgadmin3/src/frm/frmEditGrid.cpp
Log:
Fix PK detection in EditGrid

Modified: branches/REL-1_4_0_PATCHES/pgadmin3/src/frm/frmEditGrid.cpp
===================================================================
--- branches/REL-1_4_0_PATCHES/pgadmin3/src/frm/frmEditGrid.cpp    2005-12-26 14:39:11 UTC (rev 4857)
+++ branches/REL-1_4_0_PATCHES/pgadmin3/src/frm/frmEditGrid.cpp    2005-12-26 14:45:34 UTC (rev 4858)
@@ -1158,7 +1158,7 @@

     pgSet *colSet=connection->ExecuteSet(
         wxT("SELECT n.nspname AS nspname, relname, t.typname, nt.nspname AS typnspname, ")
-               wxT("attname, COALESCE(b.oid, t.oid) AS basetype, atthasdef, adsrc,\n")
+               wxT("attname, attnum, COALESCE(b.oid, t.oid) AS basetype, atthasdef, adsrc,\n")
         wxT("       CASE WHEN t.typbasetype::oid=0 THEN att.atttypmod else t.typtypmod END AS typmod,\n")
         wxT("       CASE WHEN t.typbasetype::oid=0 THEN att.attlen else t.typlen END AS typlen\n")
         wxT("  FROM pg_attribute att\n")
@@ -1279,23 +1279,20 @@
             if (!columns[i].attr->IsReadOnly())
                 canInsert=true;

-            colSet->MoveNext();
-        }
-        delete colSet;
-
-        if (!hasOids)
-        {
             wxStringTokenizer collist(primaryKeyColNumbers, wxT(","));
-            long cn;
-            int pkcolcount=0;
+            long cn=0;
+            long attnum=colSet->GetLong(wxT("attnum"));

-            while (collist.HasMoreTokens())
+            while (cn < attnum && collist.HasMoreTokens())
             {
-                pkcolcount++;
                 cn=StrToLong(collist.GetNextToken());
-                columns[cn-1].isPrimaryKey = true;
+                if (cn == attnum)
+                    columns[i].isPrimaryKey = true;
             }
+
+            colSet->MoveNext();
         }
+        delete colSet;
     }
     else
     {


pgadmin-hackers by date:

Previous
From: svn@pgadmin.org
Date:
Subject: SVN Commit by andreas: r4857 - in trunk/pgadmin3: . src/frm
Next
From: Raphaël Enrici
Date:
Subject: pgAgent manpage