Committed by =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <[email protected]>

Allow '%' again for the type in table_info() and thus
tables()

It's not documented or tested in DBI, but it used to work until
DBD::Pg 3.4.0, and the change broke DBIx::Class::Schema::Loader, which
uses type='%'.
---
 Pg.pm          |  2 +-
 t/03dbmethod.t | 13 +++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/Pg.pm b/Pg.pm
index eb63925..c6daaca 100644
--- a/Pg.pm
+++ b/Pg.pm
@@ -1135,7 +1135,7 @@ use 5.008001;
                  ORDER BY "TABLE_TYPE", "TABLE_CAT", "TABLE_SCHEM", 
"TABLE_NAME"
                 };
 
-            if (defined($type) and length($type)) {
+            if (defined($type) and length($type) and $type ne '%') {
                 my $type_restrict = join ', ' =>
                                       map { $dbh->quote($_) unless /^'/ }
                                         grep {length}
diff --git a/t/03dbmethod.t b/t/03dbmethod.t
index ffcab48..5d040cd 100644
--- a/t/03dbmethod.t
+++ b/t/03dbmethod.t
@@ -26,7 +26,7 @@ my $dbh = connect_database();
 if (! $dbh) {
        plan skip_all => 'Connection to database failed, cannot continue 
testing';
 }
-plan tests => 545;
+plan tests => 547;
 
 isnt ($dbh, undef, 'Connect to database for database handle method testing');
 
@@ -483,11 +483,16 @@ is ($dbh->get_info(25), 'N', $t);
 # Test of the "table_info" database handle method
 #
 
-$t='DB handle method "table_info" works when called with undef arguments';
+$t='DB handle method "table_info" works when called with empty arguments';
 $sth = $dbh->table_info('', '', 'dbd_pg_test', '');
 my $number = $sth->rows();
 ok ($number, $t);
 
+$t='DB handle method "table_info" works when called with \'%\' arguments';
+$sth = $dbh->table_info('%', '%', 'dbd_pg_test', '%');
+$number = $sth->rows();
+ok ($number, $t);
+
 # Check required minimum fields
 $t='DB handle method "table_info" returns fields required by DBI';
 $result = $sth->fetchall_arrayref({});
@@ -1179,6 +1184,10 @@ $t='DB handle method "tables" works with a "pg_noprefix" 
attribute';
 @result = $dbh->tables('', '', 'dbd_pg_test', '', {pg_noprefix => 1});
 is ($result[0], 'dbd_pg_test', $t);
 
+$t='DB handle method "tables" works with type=\'%\'';
+@result = $dbh->tables('', '', 'dbd_pg_test', '%');
+like ($result[0], qr/dbd_pg_test/, $t);
+
 #
 # Test of the "type_info_all" database handle method
 #
-- 
1.8.4

Reply via email to