fix Postgres sequence detection for qualified sequences
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBI / Pg.pm
index 0ed3070..b218532 100644 (file)
@@ -9,7 +9,7 @@ use base qw/
 use Carp::Clan qw/^DBIx::Class/;
 use Class::C3;
 
-our $VERSION = '0.07000';
+our $VERSION = '0.07001';
 
 =head1 NAME
 
@@ -41,6 +41,10 @@ sub _setup {
     if (not defined $self->preserve_case) {
         $self->preserve_case(0);
     }
+    elsif ($self->preserve_case) {
+        $self->schema->storage->sql_maker->quote_char('"');
+        $self->schema->storage->sql_maker->name_sep('.');
+    }
 }
 
 sub _table_uniq_info {
@@ -141,6 +145,7 @@ sub _columns_info_for {
         my $data_type = $info->{data_type};
 
         # these types are fixed size
+        # XXX should this be a negative match?
         if ($data_type =~
 /^(?:bigint|int8|bigserial|serial8|boolean|bool|box|bytea|cidr|circle|date|double precision|float8|inet|integer|int|int4|line|lseg|macaddr|money|path|point|polygon|real|float4|smallint|int2|serial|serial4|text)\z/i) {
             delete $info->{size};
@@ -221,16 +226,19 @@ EOF
         }
 
 # process SERIAL columns
-        if (ref($info->{default_value}) eq 'SCALAR' && ${ $info->{default_value} } =~ /\bnextval\(['"](\w+)/i) {
+        if (ref($info->{default_value}) eq 'SCALAR' && ${ $info->{default_value} } =~ /\bnextval\(['"]([.\w]+)/i) {
             $info->{is_auto_increment} = 1;
             $info->{sequence}          = $1;
             delete $info->{default_value};
         }
 
 # alias now() to current_timestamp for deploying to other DBs
-        if ((eval { lc ${ $info->{default_value} }||'') eq 'now()' }) {
+        if ((eval { lc ${ $info->{default_value} } }||'') eq 'now()') {
             # do not use a ref to a constant, that breaks Data::Dump output
             ${$info->{default_value}} = 'current_timestamp';
+
+            my $now = 'now()';
+            $info->{original}{default_value} = \$now;
         }
     }