[Bps-public-commit] r13746 - in DBIx-SearchBuilder/trunk: SearchBuilder/Handle

sartak at bestpractical.com sartak at bestpractical.com
Wed Jul 2 21:46:17 EDT 2008


Author: sartak
Date: Wed Jul  2 21:46:16 2008
New Revision: 13746

Modified:
   DBIx-SearchBuilder/trunk/   (props changed)
   DBIx-SearchBuilder/trunk/SearchBuilder/Handle/SQLite.pm

Log:
 r63642 at onn:  sartak | 2008-07-02 21:46:09 -0400
 Override EndTransaction instead of Rollback because users can (and do) use EndTransaction directly


Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Handle/SQLite.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Handle/SQLite.pm	(original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Handle/SQLite.pm	Wed Jul  2 21:46:16 2008
@@ -132,23 +132,35 @@
     $$statementref = "SELECT count(*) FROM (SELECT DISTINCT main.id FROM $$statementref )";
 }
 
-=head3 Rollback [FORCE]
+=head3 EndTransaction [Action => 'commit'] [Force => 0]
 
-Tells to abort the current SQL transaction.
+Tells to end the current transaction. Takes C<Action> argument
+that could be C<commit> or C<rollback>, the default value
+is C<commit>.
 
-Method uses C<EndTransaction> method, read its
-L<description|DBIx::SearchBuilder::Handle/EndTransaction>.
+If C<Force> argument is true then all nested transactions
+would be committed or rolled back.
 
-The SQLite Rollback has the flush the Record::Cachable cache because
+If there is no transaction in progress then method throw
+warning unless action is forced.
+
+Method returns true on success or false if error occured.
+
+Rolling back a SQLite transaction flushes the Record::Cachable cache because
 the primarily keys are reused, unlike many other database systems.
 
 =cut
 
-sub Rollback {
+sub EndTransaction {
     my $self = shift;
+    my %args = (Action => 'commit', @_);
+    my $action = lc $args{'Action'} eq 'commit' ? 'commit': 'rollback';
+
     DBIx::SearchBuilder::Record::Cachable->FlushCache
-        if DBIx::SearchBuilder::Record::Cachable->can('FlushCache');
-    $self->SUPER::Rollback(@_);
+        if $action eq 'rollback'
+        && DBIx::SearchBuilder::Record::Cachable->can('FlushCache');
+
+    $self->SUPER::EndTransaction(@_);
 }
 
 1;



More information about the Bps-public-commit mailing list