Check truth of preserve_case not definedness
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBI / Pg.pm
index 57d9eb7..4b035ab 100644 (file)
@@ -2,13 +2,10 @@ package DBIx::Class::Schema::Loader::DBI::Pg;
 
 use strict;
 use warnings;
-use base qw/
-    DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault
-    DBIx::Class::Schema::Loader::DBI
-/;
+use base 'DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault';
 use mro 'c3';
 
-our $VERSION = '0.07012';
+our $VERSION = '0.07022';
 
 =head1 NAME
 
@@ -28,7 +25,7 @@ sub _setup {
 
     $self->{db_schema} ||= ['public'];
 
-    if (not defined $self->preserve_case) {
+    if (not $self->preserve_case) {
         $self->preserve_case(0);
     }
     elsif ($self->preserve_case) {
@@ -78,7 +75,7 @@ sub _table_uniq_info {
           c.relname     = ?}
     );
 
-    $uniq_sth->execute($table->schema, $table);
+    $uniq_sth->execute($table->schema, $table->name);
     while(my $row = $uniq_sth->fetchrow_arrayref) {
         my ($tableid, $indexname, $col_nums) = @$row;
         $col_nums =~ s/^\s+//;
@@ -88,7 +85,7 @@ sub _table_uniq_info {
         foreach (@col_nums) {
             $attr_sth->execute($tableid, $_);
             my $name_aref = $attr_sth->fetchrow_arrayref;
-            push(@col_names, $name_aref->[0]) if $name_aref;
+            push(@col_names, $self->_lc($name_aref->[0])) if $name_aref;
         }
 
         if(!@col_names) {
@@ -111,8 +108,8 @@ sub _table_comment {
     return $table_comment if $table_comment;
 
     ($table_comment) = $self->dbh->selectrow_array(<<'EOF', {}, $table->name, $table->schema);
-SELECT obj_description(oid) 
-FROM pg_class 
+SELECT obj_description(oid)
+FROM pg_class
 WHERE relname=? AND relnamespace=(SELECT oid FROM pg_namespace WHERE nspname=?)
 EOF
 
@@ -130,7 +127,7 @@ sub _column_comment {
 
     my ($table_oid) = $self->dbh->selectrow_array(<<'EOF', {}, $table->name, $table->schema);
 SELECT oid
-FROM pg_class 
+FROM pg_class
 WHERE relname=? AND relnamespace=(SELECT oid FROM pg_namespace WHERE nspname=?)
 EOF
 
@@ -164,7 +161,7 @@ sub _columns_info_for {
             }
 
             my ($precision) = $self->schema->storage->dbh
-                ->selectrow_array(<<EOF, {}, $table, $col);
+                ->selectrow_array(<<EOF, {}, $table->name, $col);
 SELECT datetime_precision
 FROM information_schema.columns
 WHERE table_name = ? and column_name = ?
@@ -199,7 +196,7 @@ EOF
         elsif ($data_type =~ /^(?:bit(?: varying)?|varbit)\z/i) {
             $info->{data_type} = 'varbit' if $data_type =~ /var/i;
 
-            my ($precision) = $self->dbh->selectrow_array(<<EOF, {}, $table, $col);
+            my ($precision) = $self->dbh->selectrow_array(<<EOF, {}, $table->name, $col);
 SELECT character_maximum_length
 FROM information_schema.columns
 WHERE table_name = ? and column_name = ?
@@ -251,7 +248,7 @@ EOF
                 $info->{extra}{custom_type_name} = $info->{data_type};
 
                 $info->{data_type} = 'enum';
-                
+
                 delete $info->{size};
             }
         }