Patch against v0.11005 attached.

Andrew

Index: lib/SQL/Translator/Parser/DBI/PostgreSQL.pm
===================================================================
--- lib/SQL/Translator/Parser/DBI/PostgreSQL.pm	(revision 1)
+++ lib/SQL/Translator/Parser/DBI/PostgreSQL.pm	(working copy)
@@ -56,9 +56,10 @@
 
     my $column_select = $dbh->prepare(
       "SELECT a.attname, t.typname, a.attnum,a.atttypmod as length,
-              a.attnotnull, a.atthasdef, d.adsrc
+              a.attnotnull, a.atthasdef, d.adsrc, description
        FROM pg_type t,pg_attribute a
        LEFT JOIN pg_attrdef d ON (d.adrelid = a.attrelid AND a.attnum = d.adnum)
+       LEFT JOIN pg_description ON (a.attrelid=objoid AND a.attnum=objsubid)
        WHERE a.attrelid=? AND attnum>0
          AND a.atttypid=t.oid
        ORDER BY a.attnum"
@@ -73,7 +74,9 @@
     );
 
     my $table_select  = $dbh->prepare(
-      "SELECT oid,relname FROM pg_class WHERE relnamespace IN
+      "SELECT pg_class.oid,relname,description FROM pg_class
+          LEFT JOIN pg_description ON oid=objoid AND objsubid=0
+          WHERE relnamespace IN
           (SELECT oid FROM pg_namespace WHERE nspname='public')
           AND relkind='r';"
     );
@@ -128,6 +131,8 @@
                                        name => $table_name,
               #what is type?               type => $table_info->{TABLE_TYPE},
                                           ) || die $schema->error;
+        $table->comments($$tablehash{'description'})
+            if $$tablehash{'description'};
 
         $column_select->execute($table_oid);
 
@@ -145,6 +150,8 @@
 
             $col->{size} = [$$columnhash{'length'}] if $$columnhash{'length'}>0;
             $col->{is_nullable} = $$columnhash{'attnotnull'} ? 0 : 1;
+            $col->{comments} = [$$columnhash{'description'}]
+                if $$columnhash{'description'};
         }
 
         $index_select->execute($table_oid);

------------------------------------------------------------------------------

-- 
sqlfairy-developers mailing list
sqlfairy-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlfairy-developers

Reply via email to