From 89258929181ac3b43b3b277cf9dc097851192bc5 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Tue, 23 Jul 2013 16:17:40 -0400 Subject: [PATCH] handle USER-DEFINED types Signed-off-by: Jason Etheridge --- Open-ILS/src/sql/Pg/make-pgtap-tests.pl | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/sql/Pg/make-pgtap-tests.pl b/Open-ILS/src/sql/Pg/make-pgtap-tests.pl index 314645d134..e9f85433e6 100755 --- a/Open-ILS/src/sql/Pg/make-pgtap-tests.pl +++ b/Open-ILS/src/sql/Pg/make-pgtap-tests.pl @@ -62,15 +62,20 @@ foreach my $schema ( @schemas ) { my ($schema,$table) = (shift,shift); my @columns = fetch_columns($schema,$table); foreach my $column_array ( @columns ) { + my $column = $column_array->[0]; - my $col_type = $column_array->[1]; + my $col_type_original = $column_array->[1]; + my $col_type = $col_type_original; my $col_nullable = $column_array->[2]; my $col_default = $column_array->[3]; + my $col_numeric_precision = $column_array->[4]; + my $col_numeric_scale = $column_array->[5]; + my $col_udt_schema = $column_array->[6]; + my $col_udt_name = $column_array->[7]; + if (defined $col_default && $col_default =~ /::text/) { $col_default =~ s/^'(.*)'::text$/$1/; } - my $col_numeric_precision = $column_array->[4]; - my $col_numeric_scale = $column_array->[5]; if ($col_type eq 'numeric' && defined $col_numeric_precision) { $col_type .= "($col_numeric_precision"; if (defined $col_numeric_scale) { @@ -78,6 +83,9 @@ foreach my $schema ( @schemas ) { } $col_type .= ')'; } + if ($col_type eq 'USER-DEFINED' && defined $col_udt_schema) { + $col_type = "$col_udt_schema.$col_udt_name"; + } print "\n-- -- -- column " . $dbh->quote("$schema.$table.$column") . "\n\n"; print "SELECT has_column(\n"; print "\t" . $dbh->quote($schema) . ",\n"; @@ -120,7 +128,7 @@ foreach my $schema ( @schemas ) { } elsif ($col_type eq 'integer' && $col_default =~ '\(-?\d+\)') { # FIXME - ERROR: invalid input syntax for integer: "(-1)" $fixme = '-- FIXME type 4 -- '; - } elsif ($col_type eq 'USER-DEFINED') { + } elsif ($col_type_original eq 'USER-DEFINED') { # FIXME - ERROR: Unexpected end of string $fixme = '-- FIXME type 5 -- '; } @@ -160,7 +168,6 @@ foreach my $schema ( @schemas ) { print "\t" . $dbh->quote($schema) . ",\n"; print "\t" . $dbh->quote($view) . ",\n"; print "\t" . $dbh->quote("Has view $schema.$view") . "\n);\n"; - handle_columns($schema,$view); } @@ -222,7 +229,9 @@ sub fetch_columns { is_nullable, column_default, numeric_precision, - numeric_scale + numeric_scale, + udt_schema, + udt_name FROM information_schema.columns WHERE table_catalog = ? AND table_schema = ? -- 2.11.0