From: Brandon Black Date: Wed, 25 Jan 2006 04:28:24 +0000 (+0000) Subject: more cleanup stuff, standardized usage of dbh->get_info(29) (sql quote char) X-Git-Tag: 0.03000~41 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b005807a9239c9aa5c569ca24cdfd6a0a3f5ed23;p=dbsrgits%2FDBIx-Class-Schema-Loader.git more cleanup stuff, standardized usage of dbh->get_info(29) (sql quote char) --- diff --git a/lib/DBIx/Class/Schema/Loader/DB2.pm b/lib/DBIx/Class/Schema/Loader/DB2.pm index 1f1a07e..bc56734 100644 --- a/lib/DBIx/Class/Schema/Loader/DB2.pm +++ b/lib/DBIx/Class/Schema/Loader/DB2.pm @@ -36,6 +36,7 @@ sub _loader_tables { my %args = @_; my $db_schema = uc $class->_loader_data->{db_schema}; my $dbh = $class->storage->dbh; + my $quoter = $dbh->get_info(29) || q{"}; # this is split out to avoid version parsing errors... my $is_dbd_db2_gte_114 = ( $DBD::DB2::VERSION >= 1.14 ); @@ -44,7 +45,7 @@ sub _loader_tables { : $dbh->tables; # People who use table or schema names that aren't identifiers deserve # what they get. Still, FIXME? - s/\"//g for @tables; + s/$quoter//g for @tables; @tables = grep {!/^SYSIBM\./ and !/^SYSCAT\./ and !/^SYSSTAT\./} @tables; @tables = grep {/^$db_schema\./} @tables if($db_schema); return @tables; diff --git a/lib/DBIx/Class/Schema/Loader/Pg.pm b/lib/DBIx/Class/Schema/Loader/Pg.pm index 62515ff..4e32d48 100644 --- a/lib/DBIx/Class/Schema/Loader/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/Pg.pm @@ -32,28 +32,31 @@ sub _loader_db_classes { sub _loader_tables { my $class = shift; my $dbh = $class->storage->dbh; + my $quoter = $dbh->get_info(29) || q{"}; # This is split out to avoid version parsing errors... my $is_dbd_pg_gte_131 = ( $DBD::Pg::VERSION >= 1.31 ); - my @tables = $is_dbd_pg_gte_131 ? - $dbh->tables( undef, $class->_loader_data->{db_schema}, "", "table", { noprefix => 1, pg_noprefix => 1 } ) + my @tables = $is_dbd_pg_gte_131 + ? $dbh->tables( undef, $class->_loader_data->{db_schema}, "", + "table", { noprefix => 1, pg_noprefix => 1 } ) : $dbh->tables; - s/"//g for @tables; + s/$quoter//g for @tables; return @tables; } sub _loader_table_info { my ( $class, $table ) = @_; my $dbh = $class->storage->dbh; + my $quoter = $dbh->get_info(29) || q{"}; my $sth = $dbh->column_info(undef, $class->_loader_data->{db_schema}, $table, undef); my @cols = map { $_->[3] } @{ $sth->fetchall_arrayref }; - s/"//g for @cols; + s/$quoter//g for @cols; my @primary = $dbh->primary_key(undef, $class->_loader_data->{db_schema}, $table); - s/"//g for @primary; + s/$quoter//g for @primary; return ( \@cols, \@primary ); } diff --git a/lib/DBIx/Class/Schema/Loader/mysql.pm b/lib/DBIx/Class/Schema/Loader/mysql.pm index 834d895..99fae68 100644 --- a/lib/DBIx/Class/Schema/Loader/mysql.pm +++ b/lib/DBIx/Class/Schema/Loader/mysql.pm @@ -42,7 +42,7 @@ sub _loader_relationships { my $dbname = $conn{database} || $conn{dbname} || $conn{db}; die("Can't figure out the table name automatically.") if !$dbname; - my $quoter = $dbh->get_info(29); + my $quoter = $dbh->get_info(29) || q{`}; foreach my $table (@tables) { my $query = "SHOW CREATE TABLE ${dbname}.${table}"; @@ -80,9 +80,9 @@ sub _loader_tables { my $class = shift; my $dbh = $class->storage->dbh; my @tables; + my $quoter = $dbh->get_info(29) || q{`}; foreach my $table ( $dbh->tables ) { - my $quoter = $dbh->get_info(29); - $table =~ s/$quoter//g if ($quoter); + $table =~ s/$quoter//g; push @tables, $1 if $table =~ /\A(\w+)\z/; }