From: Peter Rabbitson Date: Sun, 30 Aug 2009 16:56:43 +0000 (+0000) Subject: Rename insert_txn to unsafe_insert X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=85aa43a2a0019ce02fa6f868cfd5d9e1e62be981;p=dbsrgits%2FDBIx-Class-Historic.git Rename insert_txn to unsafe_insert --- diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 46915ba..e9b35e3 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 unsafe_insert/ ); =head1 NAME @@ -65,10 +65,6 @@ sub _rebless { } else { # real Sybase my $no_bind_vars = 'DBIx::Class::Storage::DBI::Sybase::NoBindVars'; -# This is reset to 0 in ::NoBindVars, only necessary because we use max(col) to -# get the identity. - $self->insert_txn(1); - if ($self->using_freetds) { carp <<'EOF' unless $ENV{DBIC_SYBASE_FREETDS_NOWARN}; @@ -181,13 +177,13 @@ L, To manipulate this setting at runtime, use: - $schema->storage->insert_txn(0); # 1 to re-enable + $schema->storage->unsafe_insert(0|1); =cut sub connect_call_unsafe_insert { my $self = shift; - $self->insert_txn(0); + $self->unsafe_insert(1); } sub _is_lob_type { @@ -313,8 +309,9 @@ sub insert { # We have to do the insert in a transaction to avoid race conditions with the # SELECT MAX(COL) identity method used when placeholders are enabled. my $updated_cols = do { - if ($need_last_insert_id && $self->insert_txn && - (not $self->{transaction_depth})) { + if ( + $need_last_insert_id && !$self->unsafe_insert && !$self->{transaction_depth} + ) { my $guard = $self->txn_scope_guard; my $upd_cols = $self->next::method (@_); $guard->commit; @@ -631,7 +628,7 @@ Some workarounds: =over 4 -=item * set C<< $schema->storage->insert_txn(0) >> temporarily (see +=item * set C<< $schema->storage->unsafe_insert(1) >> temporarily (see L) =item * use L diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm index 77c8321..d40d0a6 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm @@ -11,7 +11,9 @@ use Scalar::Util (); sub _rebless { my $self = shift; $self->disable_sth_caching(1); - $self->insert_txn(0); + $self->unsafe_insert(1); # there is nothing unsafe as the + # last_insert_id mechanism is different + # without bindvars } # this works when NOT using placeholders diff --git a/t/746sybase.t b/t/746sybase.t index 7a71bd0..a3b4d6f 100644 --- a/t/746sybase.t +++ b/t/746sybase.t @@ -312,8 +312,8 @@ SQL local $TODO = 'not supported yet or possibly ever'; SKIP: { - skip 'not testing insert with active cursor unless using insert_txn', 1 - unless $schema->storage->insert_txn; + skip 'not testing insert with active cursor if using unsafe_insert', 1 + if $schema->storage->unsafe_insert; my $artist_rs = $schema->resultset('Artist'); $artist_rs->first;