handle character type
authorJason Etheridge <jason@esilibrary.com>
Tue, 23 Jul 2013 20:23:48 +0000 (16:23 -0400)
committerJason Etheridge <jason@esilibrary.com>
Tue, 23 Jul 2013 20:23:48 +0000 (16:23 -0400)
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/src/sql/Pg/make-pgtap-tests.pl

index e9f8543..983efca 100755 (executable)
@@ -72,6 +72,7 @@ foreach my $schema ( @schemas ) {
             my $col_numeric_scale = $column_array->[5];
             my $col_udt_schema = $column_array->[6];
             my $col_udt_name = $column_array->[7];
+            my $col_character_maximum_length = $column_array->[8];
 
             if (defined $col_default && $col_default =~ /::text/) {
                 $col_default =~ s/^'(.*)'::text$/$1/;
@@ -86,6 +87,10 @@ foreach my $schema ( @schemas ) {
             if ($col_type eq 'USER-DEFINED' && defined $col_udt_schema) {
                 $col_type = "$col_udt_schema.$col_udt_name";
             }
+            if ($col_type eq 'character' && defined $col_character_maximum_length) {
+                $col_type .= "($col_character_maximum_length)";
+            }
+
             print "\n-- -- -- column " . $dbh->quote("$schema.$table.$column") . "\n\n";
             print "SELECT has_column(\n";
             print "\t" . $dbh->quote($schema) . ",\n";
@@ -231,7 +236,8 @@ sub fetch_columns {
             numeric_precision,
             numeric_scale,
             udt_schema,
-            udt_name
+            udt_name,
+            character_maximum_length
         FROM information_schema.columns
             WHERE table_catalog = ?
             AND table_schema = ?