Fix pgdatadiff.
authorRadek Brich <radek.brich@devl.cz>
Tue, 06 Sep 2011 17:55:15 +0200
changeset 12 203be9022b46
parent 11 bc69eca59041
child 13 16dc5dec9c36
Fix pgdatadiff.
pgtoolkit/pgbrowser.py
pgtoolkit/pgdatadiff.py
--- a/pgtoolkit/pgbrowser.py	Fri Aug 19 17:08:34 2011 +0200
+++ b/pgtoolkit/pgbrowser.py	Tue Sep 06 17:55:15 2011 +0200
@@ -208,9 +208,10 @@
             ORDER BY 1;
             ''', schema)
 
-    def list_columns(self, table, schema='public'):
+    def list_columns(self, table, schema='public', order=2):
         return self._query('''
             SELECT
+                a.attrelid,
                 a.attname as "name",
                 format_type(a.atttypid, a.atttypmod) AS "type",
                 a.attnotnull as "notnull",
@@ -222,8 +223,7 @@
             LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
             LEFT JOIN pg_catalog.pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE n.nspname = %s AND c.relname = %s AND a.attnum > 0 AND NOT a.attisdropped
-            ORDER BY 1
-            ''', schema, table)
+            ORDER BY ''' + str(order), schema, table)
 
     def list_constraints(self, table, schema='public'):
         return self._query('''
--- a/pgtoolkit/pgdatadiff.py	Fri Aug 19 17:08:34 2011 +0200
+++ b/pgtoolkit/pgdatadiff.py	Tue Sep 06 17:55:15 2011 +0200
@@ -190,7 +190,7 @@
 
     def _select(self):
         browser = pgbrowser.PgBrowser(self.conn1)
-        columns = browser.list_columns(schema=self.schema1, table=self.table1)
+        columns = browser.list_columns(schema=self.schema1, table=self.table1, order=1)
         columns_sel = ', '.join(['"' + x['name'] + '"' for x in columns])
         self.colnames = [x['name'] for x in columns]