From: Rafael Kitover Date: Thu, 30 Jul 2009 14:55:35 +0000 (+0000) Subject: better rebless check for insert X-Git-Tag: v0.08109~47^2~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e34bae3a2a4b92ca2e825f29bdde33d972ed8dd0;p=dbsrgits%2FDBIx-Class.git better rebless check for insert --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index b711230..db51e01 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -15,8 +15,8 @@ use Scalar::Util(); use List::Util(); __PACKAGE__->mk_group_accessors('simple' => - qw/_connect_info _dbi_connect_info _dbh _sql_maker _sql_maker_opts - _conn_pid _conn_tid transaction_depth _dbh_autocommit savepoints/ + qw/_connect_info _dbi_connect_info _dbh _sql_maker _sql_maker_opts _conn_pid + _conn_tid transaction_depth _dbh_autocommit _driver_determined savepoints/ ); # the values for these accessors are picked out (and deleted) from @@ -763,7 +763,7 @@ sub _populate_dbh { sub _determine_driver { my ($self) = @_; - if (ref $self eq 'DBIx::Class::Storage::DBI') { + if (not $self->_driver_determined) { my $driver; if ($self->_dbh) { # we are connected @@ -780,6 +780,8 @@ sub _determine_driver { bless $self, $storage_class; $self->_rebless(); } + + $self->_driver_determined(1); } } @@ -1142,7 +1144,7 @@ sub _execute { sub insert { my ($self, $source, $to_insert) = @_; - if ((not $self->_dbh) && ref($self) eq __PACKAGE__) { + if (not $self->_driver_determined) { $self->_determine_driver; goto $self->can('insert'); } diff --git a/t/746mssql.t b/t/746mssql.t index f9cbf85..14a3162 100644 --- a/t/746mssql.t +++ b/t/746mssql.t @@ -100,6 +100,9 @@ CREATE TABLE artist ( SQL }); +# start disconnected to make sure insert works on an un-reblessed storage +$schema = DBICTest::Schema->connect($dsn, $user, $pass); + my $row; lives_ok { $row = $schema->resultset('ArtistGUID')->create({ name => 'mtfnpy' })