From: Rafael Kitover Date: Sat, 29 Aug 2009 19:08:51 +0000 (+0000) Subject: fix inserts with active cursors X-Git-Tag: v0.08112~14^2~42 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=166c656193b56e08b472c675e92b9076aac03a53;p=dbsrgits%2FDBIx-Class.git fix inserts with active cursors --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 1c1ddfe..eb923d1 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1078,12 +1078,11 @@ sub txn_begin { sub _dbh_begin_work { my $self = shift; - # being here implies we have AutoCommit => 1 - # if the user is utilizing txn_do - good for - # him, otherwise we need to ensure that the - # $dbh is healthy on BEGIN - my $dbh_method = $self->{_in_dbh_do} ? '_dbh' : 'dbh'; - $self->$dbh_method->begin_work; + if ($self->{_in_dbh_do}) { + $self->_dbh->begin_work; + } else { + $self->dbh_do(sub { $_[1]->begin_work }); + } } sub txn_commit { diff --git a/lib/DBIx/Class/Storage/DBI/NoBindVars.pm b/lib/DBIx/Class/Storage/DBI/NoBindVars.pm index 030ad9f..ada367b 100644 --- a/lib/DBIx/Class/Storage/DBI/NoBindVars.pm +++ b/lib/DBIx/Class/Storage/DBI/NoBindVars.pm @@ -59,7 +59,7 @@ sub _prep_for_execute { foreach my $data (@$bound) { $data = ''.$data if ref $data; - $data = $self->_prep_bind_value($datatype, $data) + $data = $self->_prep_interpolated_value($datatype, $data) if $datatype; $data = $self->_dbh->quote($data) @@ -95,14 +95,14 @@ sub should_quote_value { return 1; } -=head2 _prep_bind_value +=head2 _prep_interpolated_value Given a datatype and the value to be inserted directly into a SQL query, returns the necessary string to represent that value (by e.g. adding a '$' sign) =cut -sub _prep_bind_value { +sub _prep_interpolated_value { #my ($self, $datatype, $value) = @_; return $_[2]; } diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 886308d..6be2943 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -12,7 +12,7 @@ use Carp::Clan qw/^DBIx::Class/; use List::Util (); __PACKAGE__->mk_group_accessors('simple' => - qw/_identity _blob_log_on_update insert_txn/ + qw/_identity _blob_log_on_update insert_txn _extra_dbh/ ); =head1 NAME @@ -34,7 +34,8 @@ also enable that driver explicitly, see the documentation for more details. With this driver there is unfortunately no way to get the C without doing a C