Showing 8 changed files with 80 additions and 139 deletions
+4
Changes
... ...
@@ -1,3 +1,7 @@
1
+0.1603
2
+  removed DBIx::Custom commit method (not backword compatible)
3
+  removed DBIx::Custom rollback method (not backword compatible)
4
+  removed DBIx::Custom auto_commit method (not backword compatible)
1 5
 0.1602
2 6
   added cache_method attribute
3 7
 0.1601
+39 -102
lib/DBIx/Custom.pm
... ...
@@ -470,33 +470,6 @@ sub register_filter {
470 470
     return $invocant;
471 471
 }
472 472
 
473
-sub auto_commit {
474
-    my $self = shift;
475
-    
476
-    # Not connected
477
-    croak "Not connected" unless $self->dbh;
478
-    
479
-    if (@_) {
480
-        
481
-        # Set AutoCommit
482
-        $self->dbh->{AutoCommit} = $_[0];
483
-        
484
-        return $self;
485
-    }
486
-    return $self->dbh->{AutoCommit};
487
-}
488
-
489
-sub commit   { 
490
-    my $ret = eval { shift->dbh->commit };
491
-    croak $@ if $@;
492
-    return $ret;
493
-}
494
-sub rollback {
495
-    my $ret = eval { shift->dbh->rollback };
496
-    croak $@ if $@;
497
-    return $ret;
498
-}
499
-
500 473
 sub DESTROY {
501 474
     my $self = shift;
502 475
     
... ...
@@ -508,18 +481,13 @@ sub DESTROY {
508 481
 
509 482
 DBIx::Custom - DBI with hash parameter binding and filtering system
510 483
 
511
-=head1 VERSION
512
-
513
-Version 0.1602
514
-
515 484
 =cut
516 485
 
517
-our $VERSION = '0.1602';
518
-$VERSION = eval $VERSION;
486
+our $VERSION = '0.1603';
519 487
 
520 488
 =head1 STABILITY
521 489
 
522
-This module is not stable. Method name and functionality will be change.
490
+This module is not stable. Method name and implementations will be change.
523 491
 
524 492
 =head1 SYNOPSYS
525 493
     
... ...
@@ -632,28 +600,28 @@ And have useful method such as insert(), update(), delete(), and select().
632 600
 
633 601
 =head1 ATTRIBUTES
634 602
 
635
-=head2 user
603
+=head2 C<user>
636 604
 
637 605
 Database user name.
638 606
     
639 607
     $dbi  = $dbi->user('Ken');
640 608
     $user = $dbi->user;
641 609
     
642
-=head2 password
610
+=head2 C<password>
643 611
 
644 612
 Database password.
645 613
     
646 614
     $dbi      = $dbi->password('lkj&le`@s');
647 615
     $password = $dbi->password;
648 616
 
649
-=head2 data_source
617
+=head2 C<data_source>
650 618
 
651 619
 Database data source.
652 620
     
653 621
     $dbi         = $dbi->data_source("dbi:mysql:dbname=$database");
654 622
     $data_source = $dbi->data_source;
655 623
     
656
-=head2 dbh
624
+=head2 C<dbh>
657 625
 
658 626
 Database handle. This is the innstance of L<DBI>
659 627
     
... ...
@@ -665,7 +633,7 @@ You can use all methods of L<DBI>
665 633
     my $sth    = $dbi->dbh->prepare("...");
666 634
     my $errstr = $dbi->dbh->errstr;
667 635
     
668
-=head2 filters
636
+=head2 C<filters>
669 637
 
670 638
 Filters
671 639
 
... ...
@@ -677,21 +645,21 @@ encode_utf8 and decode_utf8 is set to this attribute by default.
677 645
     $encode_utf8 = $dbi->filters->{encode_utf8};
678 646
     $decode_utf8 = $dbi->filters->{decode_utf8};
679 647
 
680
-=head2 default_query_filter
648
+=head2 C<default_query_filter>
681 649
 
682 650
 Default query filter.
683 651
 
684 652
     $dbi                  = $dbi->default_query_filter('encode_utf8');
685 653
     $default_query_filter = $dbi->default_query_filter
686 654
 
687
-=head2 default_fetch_filter
655
+=head2 C<default_fetch_filter>
688 656
 
689 657
 Fetching filter.
690 658
 
691 659
     $dbi                  = $dbi->default_fetch_filter('decode_utf8');
692 660
     $default_fetch_filter = $dbi->default_fetch_filter;
693 661
 
694
-=head2 result_class
662
+=head2 C<result_class>
695 663
 
696 664
 Result class.
697 665
 
... ...
@@ -700,7 +668,7 @@ Result class.
700 668
 
701 669
 L<DBIx::Custom::Result> is set to this attribute by default.
702 670
 
703
-=head2 sql_template
671
+=head2 C<sql_template>
704 672
 
705 673
 SQLTemplate instance. sql_template attribute must be 
706 674
 the instance of L<DBIx::Cutom::SQLTemplate> subclass.
... ...
@@ -716,7 +684,7 @@ this attribute by default.
716 684
 This class is L<Object::Simple> subclass.
717 685
 You can use all methods of L<Object::Simple>
718 686
 
719
-=head2 connect
687
+=head2 C<connect>
720 688
 
721 689
 Connect to database.
722 690
     
... ...
@@ -726,7 +694,7 @@ Connect to database.
726 694
 "AutoCommit" and "RaiseError" option is true, 
727 695
 and "PrintError" option is false by dfault.
728 696
 
729
-=head2 disconnect
697
+=head2 C<disconnect>
730 698
 
731 699
 Disconnect database.
732 700
 
... ...
@@ -734,7 +702,7 @@ Disconnect database.
734 702
 
735 703
 If database is already disconnected, this method do nothing.
736 704
 
737
-=head2 insert
705
+=head2 C<insert>
738 706
 
739 707
 Insert row.
740 708
 
... ...
@@ -753,7 +721,7 @@ Example:
753 721
                  append => "some statement",
754 722
                  filter => {title => 'encode_utf8'})
755 723
 
756
-=head2 update
724
+=head2 C<update>
757 725
 
758 726
 Update rows.
759 727
 
... ...
@@ -774,7 +742,7 @@ Example:
774 742
                  append => "some statement",
775 743
                  filter => {title => 'encode_utf8'});
776 744
 
777
-=head2 update_all
745
+=head2 C<update_all>
778 746
 
779 747
 Update all rows.
780 748
 
... ...
@@ -792,7 +760,7 @@ Example:
792 760
                      param  => {author => 'taro'},
793 761
                      filter => {author => 'encode_utf8'});
794 762
 
795
-=head2 delete
763
+=head2 C<delete>
796 764
 
797 765
 Delete rows.
798 766
 
... ...
@@ -811,7 +779,7 @@ Example:
811 779
                  append => 'some statement',
812 780
                  filter => {id => 'encode_utf8'});
813 781
 
814
-=head2 delete_all
782
+=head2 C<delete_all>
815 783
 
816 784
 Delete all rows.
817 785
 
... ...
@@ -824,7 +792,7 @@ Example:
824 792
     # delete_all
825 793
     $dbi->delete_all(table => 'books');
826 794
 
827
-=head2 select
795
+=head2 C<select>
828 796
     
829 797
 Select rows.
830 798
 
... ...
@@ -861,23 +829,25 @@ Example:
861 829
         relation => {'books.id' => 'rental.book_id'}
862 830
     );
863 831
 
864
-=head2 create_query
832
+=head2 C<create_query>
865 833
     
834
+    my $query = $dbi->create_query(
835
+        "select * from authors where {= name} and {= age};"
836
+    );
837
+
866 838
 Create the instance of L<DBIx::Custom::Query>. 
867 839
 This receive the string written by SQL template.
868 840
 
869
-    my $query = $dbi->create_query("select * from authors where {= name} and {= age}");
841
+=head2 C<execute>
870 842
 
871
-=head2 execute
843
+    $result = $dbi->execute($query,    param => $params, filter => {%filter});
844
+    $result = $dbi->execute($template, param => $params, filter => {%filter});
872 845
 
873 846
 Execute the instace of L<DBIx::Custom::Query> or
874 847
 the string written by SQL template.
875 848
 Return value is the instance of L<DBIx::Custom::Result>.
876 849
 
877
-    $result = $dbi->execute($query,    param => $params, filter => {%filter});
878
-    $result = $dbi->execute($template, param => $params, filter => {%filter});
879
-
880
-Example:
850
+B<Example:>
881 851
 
882 852
     $result = $dbi->execute("select * from authors where {= name} and {= age}", 
883 853
                             param => {name => 'taro', age => 19});
... ...
@@ -888,13 +858,13 @@ Example:
888 858
 
889 859
 See also L<DBIx::Custom::SQLTemplate> to know how to write SQL template.
890 860
 
891
-=head2 register_filter
861
+=head2 C<register_filter>
892 862
 
893
-Resister filter.
894
-    
895 863
     $dbi->register_filter(%filters);
896 864
     
897
-Example:
865
+Resister filter.
866
+
867
+B<Example:>
898 868
 
899 869
     $dbi->register_filter(
900 870
         encode_utf8 => sub {
... ...
@@ -913,56 +883,23 @@ Example:
913 883
         }
914 884
     );
915 885
 
916
-=head2 auto_commit
917
-
918
-Auto commit.
919
-
920
-    $self        = $dbi->auto_commit(1);
921
-    $auto_commit = $dbi->auto_commit;
922
-
923
-This is equal to
924
-
925
-    $dbi->dbh->{AutoCommit} = 1;
926
-    $auto_commit = $dbi->dbh->{AutoCommit};
927
-
928
-=head2 commit
929
-
930
-Commit.
931
-
932
-    $dbi->commit;
933
-
934
-This is equal to
935
-
936
-    $dbi->dbh->commit;
937
-
938
-=head2 rollback
939
-
940
-Rollback.
941
-
942
-    $dbi->rollback
943
-
944
-This is equal to
945
-
946
-    $dbi->dbh->rollback;
947
-
948
-=head2 cache
949
-
950
-Cache the result of parsing SQL template.
886
+=head2 C<cache>
951 887
 
952 888
     $dbi   = $dbi->cache(1);
953 889
     $cache = $dbi->cache;
954 890
 
891
+Cache the result of parsing SQL template.
955 892
 Default to 1.
956 893
 
957
-=head2 cache_method
894
+=head2 C<cache_method>
895
+
896
+    $dbi          = $dbi->cache_method(\&cache_method);
897
+    $cache_method = $dbi->cache_method
958 898
 
959 899
 Method for cache.
960 900
 
961
-    $dbi          = $dbi->cache_method(sub { ... });
962
-    $cache_method = $dbi->cache_method
901
+B<Example:>
963 902
 
964
-Example:
965
-    
966 903
     $dbi->cache_method(
967 904
         sub {
968 905
             my $self = shift;
+5 -5
lib/DBIx/Custom/MySQL.pm
... ...
@@ -53,14 +53,14 @@ DBIx::Custom::MySQL - a MySQL implementation of DBIx::Custom
53 53
 This class is L<DBIx::Custom> subclass.
54 54
 You can use all attributes of L<DBIx::Custom>
55 55
 
56
-=head2 database
56
+=head2 C<database>
57 57
 
58 58
 Database name
59 59
 
60 60
     $dbi      = $dbi->database('your_database');
61 61
     $database = $dbi->database;
62 62
 
63
-=head2 host
63
+=head2 C<host>
64 64
 
65 65
 Database host name.
66 66
 
... ...
@@ -71,7 +71,7 @@ IP address can be set to host attribute.
71 71
 
72 72
     $dbi->host('127.03.45.12');
73 73
 
74
-=head2 port
74
+=head2 C<port>
75 75
 
76 76
 Database port.
77 77
 
... ...
@@ -83,7 +83,7 @@ Database port.
83 83
 This class is L<DBIx::Custom> subclass.
84 84
 You can use all methods of L<DBIx::Custom>.
85 85
 
86
-=head2 connect - overridden
86
+=head2 C<connect (overridden)>
87 87
 
88 88
 Connect to database.
89 89
 
... ...
@@ -92,7 +92,7 @@ Connect to database.
92 92
                                            password => 'kliej&@K',
93 93
                                            database  => 'your_database');
94 94
 
95
-=head2 last_insert_id
95
+=head2 C<last_insert_id>
96 96
 
97 97
 Last insert ID.
98 98
 
+5 -5
lib/DBIx/Custom/Query.pm
... ...
@@ -20,35 +20,35 @@ DBIx::Custom::Query - query used by DBIx::Custom
20 20
     
21 21
 =head1 ATTRIBUTES
22 22
 
23
-=head2 sql
23
+=head2 C<sql>
24 24
 
25 25
 SQL statement.
26 26
 
27 27
     $query = $query->sql($sql);
28 28
     $sql   = $query->sql;
29 29
 
30
-=head2 columns
30
+=head2 C<columns>
31 31
 
32 32
 Column names.
33 33
 
34 34
     $query   = $query->columns([@columns]);
35 35
     $columns = $query->columns;
36 36
 
37
-=head2 default_filter
37
+=head2 C<default_filter>
38 38
 
39 39
 Default filter.
40 40
 
41 41
     $query          = $query->default_filter($filter);
42 42
     $default_filter = $query->default_filter;
43 43
 
44
-=head2 filter
44
+=head2 C<filter>
45 45
 
46 46
 Filter.
47 47
 
48 48
     $query  = $query->filter({%filter});
49 49
     $filter = $query->filter;
50 50
 
51
-=head2 sth
51
+=head2 C<sth>
52 52
 
53 53
 Statement handle.
54 54
 
+11 -11
lib/DBIx/Custom/Result.pm
... ...
@@ -213,21 +213,21 @@ DBIx::Custom::Result - DBIx::Custom Resultset
213 213
 
214 214
 =head1 ATTRIBUTES
215 215
 
216
-=head2 sth
216
+=head2 C<sth>
217 217
 
218 218
 Statement handle.
219 219
 
220 220
     $result = $result->sth($sth);
221 221
     $sth    = $reuslt->sth
222 222
     
223
-=head2 default_filter
223
+=head2 C<default_filter>
224 224
 
225 225
 Default filter.
226 226
 
227 227
     $result         = $result->default_filter('decode_utf8');
228 228
     $default_filter = $result->default_filter;
229 229
 
230
-=head2 filter
230
+=head2 C<filter>
231 231
 
232 232
 Filter
233 233
 
... ...
@@ -239,7 +239,7 @@ Filter
239 239
 This class is L<Object::Simple> subclass.
240 240
 You can use all methods of L<Object::Simple>
241 241
 
242
-=head2 fetch
242
+=head2 C<fetch>
243 243
 
244 244
 Fetch a row into array
245 245
 
... ...
@@ -253,13 +253,13 @@ Example:
253 253
         my $value2 = $row->[1];
254 254
     }
255 255
 
256
-=head2 fetch_first
256
+=head2 C<fetch_first>
257 257
 
258 258
 Fetch only first row into array and finish statment handle.
259 259
 
260 260
     $row = $result->fetch_first;
261 261
 
262
-=head2 fetch_multi
262
+=head2 C<fetch_multi>
263 263
 
264 264
 Fetch multiple rows into array of array.
265 265
 
... ...
@@ -271,13 +271,13 @@ Example:
271 271
         # do someting
272 272
     }
273 273
 
274
-=head2 fetch_all
274
+=head2 C<fetch_all>
275 275
 
276 276
 Fetch all rows into array of array.
277 277
 
278 278
     $rows = $result->fetch_all;
279 279
 
280
-=head2 fetch_hash
280
+=head2 C<fetch_hash>
281 281
 
282 282
 Fetch a row into hash
283 283
 
... ...
@@ -292,13 +292,13 @@ Example:
292 292
         # do something
293 293
     }
294 294
 
295
-=head2 fetch_hash_first
295
+=head2 C<fetch_hash_first>
296 296
     
297 297
 Fetch only first row into hash and finish statment handle.
298 298
 
299 299
     $row = $result->fetch_hash_first;
300 300
 
301
-=head2 fetch_hash_multi
301
+=head2 C<fetch_hash_multi>
302 302
 
303 303
 Fetch multiple rows into array of hash
304 304
 
... ...
@@ -310,7 +310,7 @@ Example:
310 310
         # do someting
311 311
     }
312 312
 
313
-=head2 fetch_hash_all
313
+=head2 C<fetch_hash_all>
314 314
 
315 315
 Fetch all rows into array of hash.
316 316
 
+8 -8
lib/DBIx/Custom/SQLTemplate.pm
... ...
@@ -222,27 +222,27 @@ DBIx::Custom::SQLTemplate - DBIx::Custom SQL Template
222 222
 
223 223
 =head1 ATTRIBUTES
224 224
 
225
-=head2 tag_processors
225
+=head2 C<tag_processors>
226 226
 
227 227
     $sql_tmpl       = $sql_tmpl->tag_processors($name1 => $tag_processor1
228 228
                                                 $name2 => $tag_processor2);
229 229
     $tag_processors = $sql_tmpl->tag_processors;
230 230
 
231
-=head2 tag_start
231
+=head2 C<tag_start>
232 232
     
233 233
     $sql_tmpl  = $sql_tmpl->tag_start('{');
234 234
     $tag_start = $sql_tmpl->tag_start;
235 235
 
236 236
 Default is '{'
237 237
 
238
-=head2 tag_end
238
+=head2 C<tag_end>
239 239
     
240 240
     $sql_tmpl    = $sql_tmpl->tag_start('}');
241 241
     $tag_end = $sql_tmpl->tag_start;
242 242
 
243 243
 Default is '}'
244 244
     
245
-=head2 tag_syntax
245
+=head2 C<tag_syntax>
246 246
     
247 247
     $sql_tmpl   = $sql_tmpl->tag_syntax($tag_syntax);
248 248
     $tag_syntax = $sql_tmpl->tag_syntax;
... ...
@@ -252,9 +252,9 @@ Default is '}'
252 252
 This class is L<Object::Simple> subclass.
253 253
 You can use all methods of L<Object::Simple>
254 254
 
255
-=head2 new
255
+=head2 C<new>
256 256
 
257
-=head2 create_query
257
+=head2 C<create_query>
258 258
     
259 259
 Create L<DBIx::Custom::Query> object parsing SQL template
260 260
 
... ...
@@ -285,7 +285,7 @@ query has two infomation
285 285
     1. sql       : SQL
286 286
     2. key_infos : Parameter access key information
287 287
 
288
-=head2 register_tag_processor
288
+=head2 C<register_tag_processor>
289 289
 
290 290
 Add tag processor
291 291
     
... ...
@@ -325,7 +325,7 @@ Key information is a little complex. so I will explan this in future.
325 325
 
326 326
 If you want to know more, Please see DBIx::Custom::SQLTemplate source code.
327 327
 
328
-=head2 clone
328
+=head2 C<clone>
329 329
 
330 330
 Clone DBIx::Custom::SQLTemplate object
331 331
 
+4 -4
lib/DBIx/Custom/SQLite.pm
... ...
@@ -63,7 +63,7 @@ DBIx::Custom::SQLite - a SQLite implementation of DBIx::Custom
63 63
 This class is L<DBIx::Custom> subclass.
64 64
 You can use all attributes of L<DBIx::Custom>.
65 65
 
66
-=head2 database
66
+=head2 C<database>
67 67
 
68 68
 Database name
69 69
 
... ...
@@ -75,7 +75,7 @@ Database name
75 75
 This class is L<DBIx::Custom> subclass.
76 76
 You can use all methods of L<DBIx::Custom>.
77 77
 
78
-=head2 connect - overridden
78
+=head2 C<connect (overridden)>
79 79
 
80 80
 Connect to database.
81 81
 
... ...
@@ -83,13 +83,13 @@ Connect to database.
83 83
 
84 84
 If you set database, host, or port, data source is automatically created.
85 85
 
86
-=head2 connect_memory
86
+=head2 C<connect_memory>
87 87
 
88 88
 Connect memory database.
89 89
 
90 90
     $dbi->connect_memory;
91 91
 
92
-=head2 last_insert_rowid
92
+=head2 C<last_insert_rowid>
93 93
 
94 94
 Last insert row ID.
95 95
 
+4 -4
t/dbix-custom-core-sqlite.t
... ...
@@ -398,19 +398,19 @@ is($dbi->filters->{encode_utf8}->('あ'),
398 398
 test 'transaction';
399 399
 $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
400 400
 $dbi->execute($CREATE_TABLE->{0});
401
-$dbi->auto_commit(0);
401
+$dbi->dbh->begin_work;
402 402
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
403 403
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
404
-$dbi->commit;
404
+$dbi->dbh->commit;
405 405
 $result = $dbi->select(table => 'table1');
406 406
 is_deeply(scalar $result->fetch_hash_all, [{key1 => 1, key2 => 2}, {key1 => 2, key2 => 3}],
407 407
           "$test : commit");
408 408
 
409 409
 $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
410 410
 $dbi->execute($CREATE_TABLE->{0});
411
-$dbi->auto_commit(0);
411
+$dbi->dbh->begin_work(0);
412 412
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
413
-$dbi->rollback;
413
+$dbi->dbh->rollback;
414 414
 
415 415
 $result = $dbi->select(table => 'table1');
416 416
 ok(! $result->fetch_first, "$test: rollback");