Merge 'trunk' into 'table_name_ref'
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Pg.pm
index f53de4b..b113a97 100644 (file)
@@ -9,7 +9,7 @@ use mro 'c3';
 use DBD::Pg qw(:pg_types);
 
 # Ask for a DBD::Pg with array support
-warn "DBD::Pg 2.9.2 or greater is strongly recommended"
+warn "DBD::Pg 2.9.2 or greater is strongly recommended\n"
   if ($DBD::Pg::VERSION < 2.009002);  # pg uses (used?) version::qv()
 
 sub with_deferred_fk_checks {
@@ -50,10 +50,18 @@ sub _dbh_get_autoinc_seq {
 
 sub get_autoinc_seq {
   my ($self,$source,$col) = @_;
-    
+
   my @pri = $source->primary_columns;
-  my ($schema,$table) = $source->name =~ /^(.+)\.(.+)$/ ? ($1,$2)
-    : (undef,$source->name);
+
+  my $schema;
+  my $table = $source->name;
+
+  if (ref $table eq 'SCALAR') {
+    $table = $$table;
+  }
+  elsif ($table =~ /^(.+)\.(.+)$/) {
+    ($schema, $table) = ($1, $2);
+  }
 
   $self->dbh_do('_dbh_get_autoinc_seq', $schema, $table, @pri);
 }
@@ -71,7 +79,7 @@ sub bind_attribute_by_data_type {
     bytea => { pg_type => DBD::Pg::PG_BYTEA },
     blob  => { pg_type => DBD::Pg::PG_BYTEA },
   };
+
   if( defined $bind_attributes->{$data_type} ) {
     return $bind_attributes->{$data_type};
   }