X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FPg.pm;h=a6648087824bb1314f801939cec0ab023366ab82;hb=2eef86336a37040fc939429b1003cd93e7c0a360;hp=3fcd550cc4a7fe01ec9679d11a1dd8790bb4a801;hpb=c70c716e091a7f4a0b9e4fc8dbbdc3d4b1841780;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Storage/DBI/Pg.pm b/lib/DBIx/Class/Storage/DBI/Pg.pm index 3fcd550..a664808 100644 --- a/lib/DBIx/Class/Storage/DBI/Pg.pm +++ b/lib/DBIx/Class/Storage/DBI/Pg.pm @@ -15,7 +15,7 @@ warn "DBD::Pg 2.9.2 or greater is strongly recommended\n" sub with_deferred_fk_checks { my ($self, $sub) = @_; - $self->dbh->do('SET CONSTRAINTS ALL DEFERRED'); + $self->_get_dbh->do('SET CONSTRAINTS ALL DEFERRED'); $sub->(); } @@ -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}; } @@ -82,26 +90,26 @@ sub bind_attribute_by_data_type { sub _sequence_fetch { my ( $self, $type, $seq ) = @_; - my ($id) = $self->dbh->selectrow_array("SELECT nextval('${seq}')"); + my ($id) = $self->_get_dbh->selectrow_array("SELECT nextval('${seq}')"); return $id; } sub _svp_begin { my ($self, $name) = @_; - $self->dbh->pg_savepoint($name); + $self->_get_dbh->pg_savepoint($name); } sub _svp_release { my ($self, $name) = @_; - $self->dbh->pg_release($name); + $self->_get_dbh->pg_release($name); } sub _svp_rollback { my ($self, $name) = @_; - $self->dbh->pg_rollback_to($name); + $self->_get_dbh->pg_rollback_to($name); } 1;