From: Rafael Kitover Date: Mon, 7 Sep 2009 19:31:38 +0000 (+0000) Subject: fix _insert_dbh code to only connect when needed, doc update X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=51ac7136944f82aa2675cc133a8d080c5fb367b1;p=dbsrgits%2FDBIx-Class-Historic.git fix _insert_dbh code to only connect when needed, doc update --- diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 6c07369..68c2e20 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -129,8 +129,6 @@ sub _populate_dbh { $self->_dbh->do('SET CHAINED ON'); } } - - $self->_insert_dbh($self->_connect(@{ $self->_dbi_connect_info })); } =head2 connect_call_blob_setup @@ -314,10 +312,13 @@ sub insert { if ( $need_last_insert_id && !$self->unsafe_insert && !$self->{transaction_depth} ) { + $self->_insert_dbh($self->_connect(@{ $self->_dbi_connect_info })) + unless $self->_insert_dbh; local $self->{_dbh} = $self->_insert_dbh; my $guard = $self->txn_scope_guard; my $upd_cols = $self->next::method (@_); $guard->commit; + $self->_insert_dbh($self->_dbh); $upd_cols; } else { @@ -621,19 +622,12 @@ C or C but has not been exhausted or L. Transactions done for inserts in C mode when placeholders are in use -are also affected, so this won't work: - - while (my $row = $rs1->next) { - $rs2->create({ foo => $row->foo }); - } +are not affected, as they use an extra database handle to do the insert. Some workarounds: =over 4 -=item * set C<< $schema->storage->unsafe_insert(1) >> temporarily (see -L) - =item * use L =item * L another L