From 2d0c05c5e8cdb8d994d24e0b3b2c0437ac6fd6af Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Wed, 24 Jul 2013 16:27:35 -0400 Subject: [PATCH] better column membership test Signed-off-by: Jason Etheridge --- Open-ILS/src/sql/Pg/make-pgtap-tests.pl | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/sql/Pg/make-pgtap-tests.pl b/Open-ILS/src/sql/Pg/make-pgtap-tests.pl index a6ec7846d8..07896fa183 100755 --- a/Open-ILS/src/sql/Pg/make-pgtap-tests.pl +++ b/Open-ILS/src/sql/Pg/make-pgtap-tests.pl @@ -240,6 +240,21 @@ sub handle_views { sub handle_columns { my ($schema,$table) = (shift,shift); my @columns = fetch_columns($schema,$table); + if (scalar @columns == 0) { + return; + } + + print "SELECT columns_are(\n"; + print "\t" . $dbh->quote($schema) . ",\n"; + print "\t" . $dbh->quote($table) . ",\n"; + print "\tARRAY[\n\t\t"; + print join( + ",\n\t\t", + map { $dbh->quote($_->[0]) } @columns + ); + print "\n\t],\t" . $dbh->quote("Found expected columns for $schema.$table"); + print "\n);\n"; + foreach my $column_array ( @columns ) { my $column = $column_array->[0]; @@ -280,11 +295,6 @@ sub handle_columns { } print "\n-- -- -- column " . $dbh->quote("$schema.$table.$column") . "\n\n"; - print "SELECT has_column(\n"; - print "\t" . $dbh->quote($schema) . ",\n"; - print "\t" . $dbh->quote($table) . ",\n"; - print "\t" . $dbh->quote($column) . ",\n"; - print "\t" . $dbh->quote("Has column $schema.$table.$column") . "\n);\n"; print "SELECT col_type_is(\n"; print "\t" . $dbh->quote($schema) . ",\n"; print "\t" . $dbh->quote($table) . ",\n"; -- 2.11.0