From: David Kamholz Date: Sat, 10 Dec 2005 21:32:04 +0000 (+0000) Subject: rename tx_* => txn_* X-Git-Tag: v0.05005~142 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=262bcbf5504159fe1925a0fbbec6104dda6b7c2d;p=dbsrgits%2FDBIx-Class.git rename tx_* => txn_* --- diff --git a/lib/DBIx/Class/DB.pm b/lib/DBIx/Class/DB.pm index 469d051..fed7507 100644 --- a/lib/DBIx/Class/DB.pm +++ b/lib/DBIx/Class/DB.pm @@ -5,8 +5,8 @@ use DBIx::Class::Storage::DBI; use DBIx::Class::ClassResolver::PassThrough; use DBI; -*dbi_commit = \&tx_commit; -*dbi_rollback = \&tx_rollback; +*dbi_commit = \&txn_commit; +*dbi_rollback = \&txn_rollback; =head1 NAME @@ -66,29 +66,29 @@ sub connection { $class->storage($storage); } -=head2 tx_begin +=head2 txn_begin Begins a transaction (does nothing if AutoCommit is off). =cut -sub tx_begin { $_[0]->storage->tx_begin } +sub txn_begin { $_[0]->storage->txn_begin } -=head2 tx_commit +=head2 txn_commit Commits the current transaction. =cut -sub tx_commit { $_[0]->storage->tx_commit } +sub txn_commit { $_[0]->storage->txn_commit } -=head2 tx_rollback +=head2 txn_rollback Rolls back the current transaction. =cut -sub tx_rollback { $_[0]->storage->tx_rollback } +sub txn_rollback { $_[0]->storage->txn_rollback } sub resolve_class { return shift->class_resolver->class(@_); } diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 4f9fe63..48edc40 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -29,14 +29,14 @@ L. Here is an example of the recommended way to use i my $obj = Genus->find(12); eval { - MyDB->tx_begin; + MyDB->txn_begin; $obj->add_to_species({ name => 'troglodyte' }); $obj->wings(2); $obj->update; cromulate($obj); # can have a nested transation - MyDB->tx_commit; + MyDB->txn_commit; }; - if ($@) { eval { MyDB->tx_rollback } } # rollback might fail, too + if ($@) { eval { MyDB->txn_rollback } } # rollback might fail, too Currently, a nested commit will do nothing and a nested rollback will die. The code at each level must be sure to call rollback in the case of an error, diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 7615adb..f53b008 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -137,23 +137,23 @@ sub _connect { return DBI->connect(@info); } -=head2 tx_begin +=head2 txn_begin Calls begin_work on the current dbh. =cut -sub tx_begin { +sub txn_begin { $_[0]->dbh->begin_work if $TRANSACTION++ == 0 and $_[0]->dbh->{AutoCommit}; } -=head2 tx_commit +=head2 txn_commit Issues a commit against the current dbh. =cut -sub tx_commit { +sub txn_commit { if ($TRANSACTION == 0) { $_[0]->dbh->commit; } @@ -162,13 +162,13 @@ sub tx_commit { } } -=head2 tx_rollback +=head2 txn_rollback Issues a rollback against the current dbh. =cut -sub tx_rollback { +sub txn_rollback { if ($TRANSACTION == 0) { $_[0]->dbh->rollback; }