From: Jason Etheridge Date: Wed, 24 Jul 2013 21:36:09 +0000 (-0400) Subject: use fetchall_hashref instead of fetchall_arrayref X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=eedd09a6adf925ab55f258e1a32d1f2d0dc1b246;p=working%2FEvergreen.git use fetchall_hashref instead of fetchall_arrayref Signed-off-by: Jason Etheridge --- diff --git a/Open-ILS/src/sql/Pg/make-pgtap-tests.pl b/Open-ILS/src/sql/Pg/make-pgtap-tests.pl index 07896fa183..76bc1e554b 100755 --- a/Open-ILS/src/sql/Pg/make-pgtap-tests.pl +++ b/Open-ILS/src/sql/Pg/make-pgtap-tests.pl @@ -169,9 +169,9 @@ sub fetch_columns { AND table_name = ? "); $sth->execute(($db_name,$schema,$table)); - my $columns = $sth->fetchall_arrayref(); + my $columns = $sth->fetchall_hashref('column_name'); $sth->finish; - return sort { $a->[0] cmp $b->[0] } (map { $_ } @{ $columns }); + return $columns; } sub handle_schemas { @@ -239,8 +239,8 @@ sub handle_views { sub handle_columns { my ($schema,$table) = (shift,shift); - my @columns = fetch_columns($schema,$table); - if (scalar @columns == 0) { + my $columns = fetch_columns($schema,$table); + if (!%{ $columns }) { return; } @@ -250,23 +250,22 @@ sub handle_columns { print "\tARRAY[\n\t\t"; print join( ",\n\t\t", - map { $dbh->quote($_->[0]) } @columns + map { $dbh->quote($_) } sort keys %{ $columns } ); print "\n\t],\t" . $dbh->quote("Found expected columns for $schema.$table"); print "\n);\n"; - foreach my $column_array ( @columns ) { + foreach my $column ( sort keys %{ $columns } ) { - my $column = $column_array->[0]; - my $col_type_original = $column_array->[1]; + my $col_type_original = $columns->{$column}->{data_type}; 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]; - my $col_character_maximum_length = $column_array->[8]; + my $col_nullable = $columns->{$column}->{is_nullable}; + my $col_default = $columns->{$column}->{column_default}; + my $col_numeric_precision = $columns->{$column}->{numeric_precision}; + my $col_numeric_scale = $columns->{$column}->{numeric_scale}; + my $col_udt_schema = $columns->{$column}->{udt_schema}; + my $col_udt_name = $columns->{$column}->{udt_name}; + my $col_character_maximum_length = $columns->{$column}->{character_maximum_length}; if (defined $col_default && $col_default =~ /::text/) { $col_default =~ s/^'(.*)'::text$/$1/;