Showing 4 changed files with 52 additions and 21 deletions
+3
Changes
... ...
@@ -1,2 +1,5 @@
1
+0.0201
2
+  rename tranzaction to transaction
3
+  add filter_off
1 4
 0.0101
2 5
   First release
+36 -15
lib/DBIx/Custom.pm
... ...
@@ -392,25 +392,25 @@ sub _build_bind_values {
392 392
     return \@bind_values;
393 393
 }
394 394
 
395
-# Run tranzaction
396
-sub run_tranzaction {
397
-    my ($self, $tranzaction) = @_;
395
+# Run transaction
396
+sub run_transaction {
397
+    my ($self, $transaction) = @_;
398 398
     
399 399
     # Check auto commit
400
-    croak("AutoCommit must be true before tranzaction start")
400
+    croak("AutoCommit must be true before transaction start")
401 401
       unless $self->_auto_commit;
402 402
     
403 403
     # Auto commit off
404 404
     $self->_auto_commit(0);
405 405
     
406
-    # Run tranzaction
407
-    eval {$tranzaction->()};
406
+    # Run transaction
407
+    eval {$transaction->()};
408 408
     
409 409
     # Tranzaction error
410
-    my $tranzaction_error = $@;
410
+    my $transaction_error = $@;
411 411
     
412 412
     # Tranzaction is failed.
413
-    if ($tranzaction_error) {
413
+    if ($transaction_error) {
414 414
         # Rollback
415 415
         eval{$self->dbh->rollback};
416 416
         
... ...
@@ -422,11 +422,11 @@ sub run_tranzaction {
422 422
         
423 423
         if ($rollback_error) {
424 424
             # Rollback is failed
425
-            croak("${tranzaction_error}Rollback is failed : $rollback_error");
425
+            croak("${transaction_error}Rollback is failed : $rollback_error");
426 426
         }
427 427
         else {
428 428
             # Rollback is success
429
-            croak("${tranzaction_error}Rollback is success");
429
+            croak("${transaction_error}Rollback is success");
430 430
         }
431 431
     }
432 432
     # Tranzaction is success
... ...
@@ -717,6 +717,17 @@ sub _add_query_cache {
717 717
     return $class;
718 718
 }
719 719
 
720
+# Both bind_filter and fetch_filter off
721
+sub filter_off {
722
+    my $self = shift;
723
+    
724
+    # filter off
725
+    $self->bind_filter(undef);
726
+    $self->fetch_filter(undef);
727
+    
728
+    return $self;
729
+}
730
+
720 731
 Object::Simple->build_class;
721 732
 
722 733
 =head1 NAME
... ...
@@ -905,6 +916,16 @@ If database is already disconnected, this method do noting.
905 916
 
906 917
     # Check connected
907 918
     $dbi->connected
919
+    
920
+=head2 filter_off
921
+
922
+    # bind_filter and fitch_filter off
923
+    $self->filter_off;
924
+    
925
+This is equeal to
926
+    
927
+    $self->bind_filter(undef);
928
+    $self->fetch_filter(undef);
908 929
 
909 930
 =head2 add_filter
910 931
 
... ...
@@ -978,14 +999,14 @@ add_filter add filter to filters
978 999
 
979 1000
 See also L<DBIx::Custom::SQL::Template>
980 1001
 
981
-=head2 run_tranzaction
1002
+=head2 run_transaction
982 1003
 
983
-    # Run tranzaction
984
-    $dbi->run_tranzaction(sub {
1004
+    # Run transaction
1005
+    $dbi->run_transaction(sub {
985 1006
         # do something
986 1007
     });
987 1008
 
988
-If tranzaction is success, commit is execute. 
1009
+If transaction is success, commit is execute. 
989 1010
 If tranzation is died, rollback is execute.
990 1011
 
991 1012
 =head2 insert
... ...
@@ -1086,7 +1107,7 @@ You must not change these mode not to damage your data.
1086 1107
 
1087 1108
 If you change these mode, 
1088 1109
 you cannot get correct error message, 
1089
-or run_tranzaction may fail.
1110
+or run_transaction may fail.
1090 1111
 
1091 1112
 =head1 AUTHOR
1092 1113
 
+7
t/01-core.t
... ...
@@ -211,3 +211,10 @@ $dbi = DBIx::Custom->new;
211 211
 $dbi->add_format(a => sub {1});
212 212
 is($dbi->formats->{a}->(), 1, $test);
213 213
 
214
+test 'filter_off';
215
+$dbi = DBIx::Custom->new;
216
+$dbi->bind_filter('a');
217
+$dbi->fetch_filter('b');
218
+$dbi->filter_off;
219
+ok(!$dbi->bind_filter,  "$test : bind_filter  off");
220
+ok(!$dbi->fetch_filter, "$test : fetch_filter off");
+6 -6
t/02-sqlite.t
... ...
@@ -406,7 +406,7 @@ is_deeply($rows, [{key1 => 6, key2 => 6, key3 => 6, key4 => 6, key5 => 5},
406 406
 test 'run_tansaction';
407 407
 $dbi->do($DROP_TABLE->{0});
408 408
 $dbi->do($CREATE_TABLE->{0});
409
-$dbi->run_tranzaction(sub {
409
+$dbi->run_transaction(sub {
410 410
     $insert_tmpl = 'insert into table1 {insert key1 key2}';
411 411
     $dbi->execute($insert_tmpl, {key1 => 1, key2 => 2});
412 412
     $dbi->execute($insert_tmpl, {key1 => 3, key2 => 4});
... ...
@@ -419,7 +419,7 @@ $dbi->do($DROP_TABLE->{0});
419 419
 $dbi->do($CREATE_TABLE->{0});
420 420
 $dbi->dbh->{RaiseError} = 0;
421 421
 eval{
422
-    $dbi->run_tranzaction(sub {
422
+    $dbi->run_transaction(sub {
423 423
         $insert_tmpl = 'insert into table1 {insert key1 key2}';
424 424
         $dbi->execute($insert_tmpl, {key1 => 1, key2 => 2});
425 425
         die "Fatal Error";
... ...
@@ -435,7 +435,7 @@ is_deeply($rows, [], "$test : rollback");
435 435
 
436 436
 test 'Error case';
437 437
 $dbi = DBIx::Custom->new;
438
-eval{$dbi->run_tranzaction};
438
+eval{$dbi->run_transaction};
439 439
 like($@, qr/Not yet connect to database/, "$test : Yet Connected");
440 440
 
441 441
 $dbi = DBIx::Custom->new(data_source => 'dbi:SQLit');
... ...
@@ -445,9 +445,9 @@ ok($@, "$test : connect error");
445 445
 $dbi = DBIx::Custom->new($NEW_ARGS->{0});
446 446
 $dbi->connect;
447 447
 $dbi->dbh->{AutoCommit} = 0;
448
-eval{$dbi->run_tranzaction()};
449
-like($@, qr/AutoCommit must be true before tranzaction start/,
450
-         "$test : run_tranzaction auto commit is false");
448
+eval{$dbi->run_transaction()};
449
+like($@, qr/AutoCommit must be true before transaction start/,
450
+         "$test : run_transaction auto commit is false");
451 451
 
452 452
 $dbi = DBIx::Custom->new($NEW_ARGS->{0});
453 453
 $sql = 'laksjdf';