| ... | ... |
@@ -3,10 +3,10 @@ use warnings; |
| 3 | 3 |
use Module::Build; |
| 4 | 4 |
|
| 5 | 5 |
my $builder = Module::Build->new( |
| 6 |
- module_name => 'DBI::Custom', |
|
| 6 |
+ module_name => 'DBIx::Custom', |
|
| 7 | 7 |
license => 'perl', |
| 8 | 8 |
dist_author => 'Yuki Kimoto <kimoto.yuki@gmail.com>', |
| 9 |
- dist_version_from => 'lib/DBI/Custom.pm', |
|
| 9 |
+ dist_version_from => 'lib/DBIx/Custom.pm', |
|
| 10 | 10 |
build_requires => {
|
| 11 | 11 |
'Test::More' => 0, |
| 12 | 12 |
}, |
| ... | ... |
@@ -16,11 +16,11 @@ my $builder = Module::Build->new( |
| 16 | 16 |
requires => {
|
| 17 | 17 |
'Object::Simple' => 2.0702, |
| 18 | 18 |
'DBI' => 1.605, |
| 19 |
- 'DBI::Custom::Query' => 0.0101, |
|
| 20 |
- 'DBI::Custom::Result' => 0.0101, |
|
| 21 |
- 'DBI::Custom::SQL::Template' => 0.0101 |
|
| 19 |
+ 'DBIx::Custom::Query' => 0.0101, |
|
| 20 |
+ 'DBIx::Custom::Result' => 0.0101, |
|
| 21 |
+ 'DBIx::Custom::SQL::Template' => 0.0101 |
|
| 22 | 22 |
}, |
| 23 |
- add_to_cleanup => [ 'DBI-Custom-*' ], |
|
| 23 |
+ add_to_cleanup => [ 'DBIx-Custom-*' ], |
|
| 24 | 24 |
create_makefile_pl => 'traditional', |
| 25 | 25 |
); |
| 26 | 26 |
|
| ... | ... |
@@ -1,10 +1,10 @@ |
| 1 |
-DBI-Custom |
|
| 1 |
+DBIx-Custom |
|
| 2 | 2 |
|
| 3 | 3 |
Custamizable DBI |
| 4 | 4 |
|
| 5 | 5 |
INSTALLATION |
| 6 | 6 |
|
| 7 |
-cpan DBI::Custom |
|
| 7 |
+cpan DBIx::Custom |
|
| 8 | 8 |
|
| 9 | 9 |
COPYRIGHT AND LICENCE |
| 10 | 10 |
|
| ... | ... |
@@ -1,13 +1,13 @@ |
| 1 |
-package DBI::Custom; |
|
| 1 |
+package DBIx::Custom; |
|
| 2 | 2 |
use Object::Simple; |
| 3 | 3 |
|
| 4 | 4 |
our $VERSION = '0.0101'; |
| 5 | 5 |
|
| 6 | 6 |
use Carp 'croak'; |
| 7 | 7 |
use DBI; |
| 8 |
-use DBI::Custom::Query; |
|
| 9 |
-use DBI::Custom::Result; |
|
| 10 |
-use DBI::Custom::SQL::Template; |
|
| 8 |
+use DBIx::Custom::Query; |
|
| 9 |
+use DBIx::Custom::Result; |
|
| 10 |
+use DBIx::Custom::SQL::Template; |
|
| 11 | 11 |
|
| 12 | 12 |
|
| 13 | 13 |
### Class-Object Accessors |
| ... | ... |
@@ -45,14 +45,14 @@ sub formats : ClassObjectAttr {
|
| 45 | 45 |
sub result_class : ClassObjectAttr {
|
| 46 | 46 |
initialize => {
|
| 47 | 47 |
clone => 'scalar', |
| 48 |
- default => 'DBI::Custom::Result' |
|
| 48 |
+ default => 'DBIx::Custom::Result' |
|
| 49 | 49 |
} |
| 50 | 50 |
} |
| 51 | 51 |
|
| 52 | 52 |
sub sql_template : ClassObjectAttr {
|
| 53 | 53 |
initialize => {
|
| 54 | 54 |
clone => sub {$_[0] ? $_[0]->clone : undef},
|
| 55 |
- default => sub {DBI::Custom::SQL::Template->new}
|
|
| 55 |
+ default => sub {DBIx::Custom::SQL::Template->new}
|
|
| 56 | 56 |
} |
| 57 | 57 |
} |
| 58 | 58 |
|
| ... | ... |
@@ -203,7 +203,7 @@ sub create_query {
|
| 203 | 203 |
$query = eval{$sql_template->create_query($template)};
|
| 204 | 204 |
croak($@) if $@; |
| 205 | 205 |
|
| 206 |
- $query = DBI::Custom::Query->new($query); |
|
| 206 |
+ $query = DBIx::Custom::Query->new($query); |
|
| 207 | 207 |
|
| 208 | 208 |
$class->_add_query_cache($template, $query); |
| 209 | 209 |
} |
| ... | ... |
@@ -721,7 +721,7 @@ Object::Simple->build_class; |
| 721 | 721 |
|
| 722 | 722 |
=head1 NAME |
| 723 | 723 |
|
| 724 |
-DBI::Custom - Customizable simple DBI |
|
| 724 |
+DBIx::Custom - Customizable simple DBI |
|
| 725 | 725 |
|
| 726 | 726 |
=head1 VERSION |
| 727 | 727 |
|
| ... | ... |
@@ -738,7 +738,7 @@ Please tell me bug if you find |
| 738 | 738 |
|
| 739 | 739 |
=head1 SYNOPSIS |
| 740 | 740 |
|
| 741 |
- my $dbi = DBI::Custom->new; |
|
| 741 |
+ my $dbi = DBIx::Custom->new; |
|
| 742 | 742 |
|
| 743 | 743 |
my $query = $dbi->create_query($template); |
| 744 | 744 |
$dbi->execute($query); |
| ... | ... |
@@ -870,7 +870,7 @@ you can get DBI database handle if you need. |
| 870 | 870 |
$result_class = $dbi->result_class; |
| 871 | 871 |
|
| 872 | 872 |
# Sample |
| 873 |
- $dbi->result_class('DBI::Custom::Result');
|
|
| 873 |
+ $dbi->result_class('DBIx::Custom::Result');
|
|
| 874 | 874 |
|
| 875 | 875 |
=head2 dbh |
| 876 | 876 |
|
| ... | ... |
@@ -885,7 +885,7 @@ you can get DBI database handle if you need. |
| 885 | 885 |
$self = $dbi->connect; |
| 886 | 886 |
|
| 887 | 887 |
# Sample |
| 888 |
- $dbi = DBI::Custom->new(user => 'taro', password => 'lji8(',
|
|
| 888 |
+ $dbi = DBIx::Custom->new(user => 'taro', password => 'lji8(',
|
|
| 889 | 889 |
data_soruce => "dbi:mysql:dbname=$database"); |
| 890 | 890 |
$dbi->connect; |
| 891 | 891 |
|
| ... | ... |
@@ -976,7 +976,7 @@ add_filter add filter to filters |
| 976 | 976 |
# do something |
| 977 | 977 |
} |
| 978 | 978 |
|
| 979 |
-See also L<DBI::Custom::SQL::Template> |
|
| 979 |
+See also L<DBIx::Custom::SQL::Template> |
|
| 980 | 980 |
|
| 981 | 981 |
=head2 run_tranzaction |
| 982 | 982 |
|
| ... | ... |
@@ -1071,11 +1071,11 @@ This method is same as DBI last_insert_id; |
| 1071 | 1071 |
$query_cache_max = $class->query_cache_max; |
| 1072 | 1072 |
|
| 1073 | 1073 |
# Sample |
| 1074 |
- DBI::Custom->query_cache_max(50); |
|
| 1074 |
+ DBIx::Custom->query_cache_max(50); |
|
| 1075 | 1075 |
|
| 1076 | 1076 |
=head1 CAUTION |
| 1077 | 1077 |
|
| 1078 |
-DBI::Custom have DIB object internal. |
|
| 1078 |
+DBIx::Custom have DIB object internal. |
|
| 1079 | 1079 |
This module is work well in the following DBI condition. |
| 1080 | 1080 |
|
| 1081 | 1081 |
1. AutoCommit is true |
| ... | ... |
@@ -3,7 +3,7 @@ |
| 3 | 3 |
use Test::More tests => 1; |
| 4 | 4 |
|
| 5 | 5 |
BEGIN {
|
| 6 |
- use_ok( 'DBI::Custom' ); |
|
| 6 |
+ use_ok( 'DBIx::Custom' ); |
|
| 7 | 7 |
} |
| 8 | 8 |
|
| 9 |
-diag( "Testing DBI::Custom $DBI::Custom::VERSION, Perl $], $^X" ); |
|
| 9 |
+diag( "Testing DBIx::Custom $DBIx::Custom::VERSION, Perl $], $^X" ); |
| ... | ... |
@@ -2,8 +2,8 @@ use Test::More 'no_plan'; |
| 2 | 2 |
use strict; |
| 3 | 3 |
use warnings; |
| 4 | 4 |
|
| 5 |
-use DBI::Custom; |
|
| 6 |
-use DBI::Custom::SQL::Template; |
|
| 5 |
+use DBIx::Custom; |
|
| 6 |
+use DBIx::Custom::SQL::Template; |
|
| 7 | 7 |
|
| 8 | 8 |
# Function for test name |
| 9 | 9 |
my $test; |
| ... | ... |
@@ -13,15 +13,15 @@ sub test {
|
| 13 | 13 |
|
| 14 | 14 |
# Variables for test |
| 15 | 15 |
our $SQL_TMPL = {
|
| 16 |
- 0 => DBI::Custom::SQL::Template->new->tag_start(0), |
|
| 17 |
- 1 => DBI::Custom::SQL::Template->new->tag_start(1), |
|
| 18 |
- 2 => DBI::Custom::SQL::Template->new->tag_start(2) |
|
| 16 |
+ 0 => DBIx::Custom::SQL::Template->new->tag_start(0), |
|
| 17 |
+ 1 => DBIx::Custom::SQL::Template->new->tag_start(1), |
|
| 18 |
+ 2 => DBIx::Custom::SQL::Template->new->tag_start(2) |
|
| 19 | 19 |
}; |
| 20 | 20 |
my $dbi; |
| 21 | 21 |
|
| 22 | 22 |
|
| 23 | 23 |
test 'Constructor'; |
| 24 |
-$dbi = DBI::Custom->new( |
|
| 24 |
+$dbi = DBIx::Custom->new( |
|
| 25 | 25 |
user => 'a', |
| 26 | 26 |
database => 'a', |
| 27 | 27 |
password => 'b', |
| ... | ... |
@@ -39,13 +39,13 @@ is_deeply($dbi,{user => 'a', database => 'a', password => 'b', data_source => 'c
|
| 39 | 39 |
dbi_options => {d => 1, e => 2}, filters => {f => 3}, bind_filter => 'f',
|
| 40 | 40 |
fetch_filter => 'g', result_class => 'g', |
| 41 | 41 |
sql_template => $SQL_TMPL->{0}}, $test);
|
| 42 |
-isa_ok($dbi, 'DBI::Custom'); |
|
| 42 |
+isa_ok($dbi, 'DBIx::Custom'); |
|
| 43 | 43 |
|
| 44 | 44 |
|
| 45 | 45 |
test 'Sub class constructor'; |
| 46 | 46 |
{
|
| 47 |
- package DBI::Custom::T1; |
|
| 48 |
- use base 'DBI::Custom'; |
|
| 47 |
+ package DBIx::Custom::T1; |
|
| 48 |
+ use base 'DBIx::Custom'; |
|
| 49 | 49 |
|
| 50 | 50 |
__PACKAGE__ |
| 51 | 51 |
->user('a')
|
| ... | ... |
@@ -61,11 +61,11 @@ test 'Sub class constructor'; |
| 61 | 61 |
) |
| 62 | 62 |
->bind_filter('f')
|
| 63 | 63 |
->fetch_filter('g')
|
| 64 |
- ->result_class('DBI::Custom::Result')
|
|
| 64 |
+ ->result_class('DBIx::Custom::Result')
|
|
| 65 | 65 |
->sql_template($SQL_TMPL->{0})
|
| 66 | 66 |
; |
| 67 | 67 |
} |
| 68 |
-$dbi = DBI::Custom::T1->new( |
|
| 68 |
+$dbi = DBIx::Custom::T1->new( |
|
| 69 | 69 |
user => 'ao', |
| 70 | 70 |
database => 'ao', |
| 71 | 71 |
password => 'bo', |
| ... | ... |
@@ -93,10 +93,10 @@ is($dbi->bind_filter, 'fo', "$test : bind_filter"); |
| 93 | 93 |
is($dbi->fetch_filter, 'go', "$test : fetch_filter"); |
| 94 | 94 |
is($dbi->result_class, 'ho', "$test : result_class"); |
| 95 | 95 |
is($dbi->sql_template->tag_start, 0, "$test : sql_template"); |
| 96 |
-isa_ok($dbi, 'DBI::Custom::T1'); |
|
| 96 |
+isa_ok($dbi, 'DBIx::Custom::T1'); |
|
| 97 | 97 |
|
| 98 | 98 |
test 'Sub class constructor default'; |
| 99 |
-$dbi = DBI::Custom::T1->new; |
|
| 99 |
+$dbi = DBIx::Custom::T1->new; |
|
| 100 | 100 |
is($dbi->user, 'a', "$test : user"); |
| 101 | 101 |
is($dbi->database, 'a', "$test : database"); |
| 102 | 102 |
is($dbi->password, 'b', "$test : password"); |
| ... | ... |
@@ -106,17 +106,17 @@ is_deeply({$dbi->filters}, {f => 3}, "$test : filters");
|
| 106 | 106 |
is_deeply({$dbi->formats}, {f => 3}, "$test : formats");
|
| 107 | 107 |
is($dbi->bind_filter, 'f', "$test : bind_filter"); |
| 108 | 108 |
is($dbi->fetch_filter, 'g', "$test : fetch_filter"); |
| 109 |
-is($dbi->result_class, 'DBI::Custom::Result', "$test : result_class"); |
|
| 109 |
+is($dbi->result_class, 'DBIx::Custom::Result', "$test : result_class"); |
|
| 110 | 110 |
is($dbi->sql_template->tag_start, 0, "$test : sql_template"); |
| 111 |
-isa_ok($dbi, 'DBI::Custom::T1'); |
|
| 111 |
+isa_ok($dbi, 'DBIx::Custom::T1'); |
|
| 112 | 112 |
|
| 113 | 113 |
|
| 114 | 114 |
test 'Sub sub class constructor default'; |
| 115 | 115 |
{
|
| 116 |
- package DBI::Custom::T1_2; |
|
| 117 |
- use base 'DBI::Custom::T1'; |
|
| 116 |
+ package DBIx::Custom::T1_2; |
|
| 117 |
+ use base 'DBIx::Custom::T1'; |
|
| 118 | 118 |
} |
| 119 |
-$dbi = DBI::Custom::T1_2->new; |
|
| 119 |
+$dbi = DBIx::Custom::T1_2->new; |
|
| 120 | 120 |
is($dbi->user, 'a', "$test : user"); |
| 121 | 121 |
is($dbi->database, 'a', "$test : database"); |
| 122 | 122 |
is($dbi->password, 'b', "$test : passowrd"); |
| ... | ... |
@@ -126,15 +126,15 @@ is_deeply(scalar $dbi->filters, {f => 3}, "$test : filters");
|
| 126 | 126 |
is_deeply(scalar $dbi->formats, {f => 3}, "$test : formats");
|
| 127 | 127 |
is($dbi->bind_filter, 'f', "$test : bind_filter"); |
| 128 | 128 |
is($dbi->fetch_filter, 'g', "$test : fetch_filter"); |
| 129 |
-is($dbi->result_class, 'DBI::Custom::Result', "$test : result_class"); |
|
| 129 |
+is($dbi->result_class, 'DBIx::Custom::Result', "$test : result_class"); |
|
| 130 | 130 |
is($dbi->sql_template->tag_start, 0, "$test sql_template"); |
| 131 |
-isa_ok($dbi, 'DBI::Custom::T1_2'); |
|
| 131 |
+isa_ok($dbi, 'DBIx::Custom::T1_2'); |
|
| 132 | 132 |
|
| 133 | 133 |
|
| 134 | 134 |
test 'Customized sub class constructor default'; |
| 135 | 135 |
{
|
| 136 |
- package DBI::Custom::T1_3; |
|
| 137 |
- use base 'DBI::Custom::T1'; |
|
| 136 |
+ package DBIx::Custom::T1_3; |
|
| 137 |
+ use base 'DBIx::Custom::T1'; |
|
| 138 | 138 |
|
| 139 | 139 |
__PACKAGE__ |
| 140 | 140 |
->user('ao')
|
| ... | ... |
@@ -154,7 +154,7 @@ test 'Customized sub class constructor default'; |
| 154 | 154 |
->sql_template($SQL_TMPL->{1})
|
| 155 | 155 |
; |
| 156 | 156 |
} |
| 157 |
-$dbi = DBI::Custom::T1_3->new; |
|
| 157 |
+$dbi = DBIx::Custom::T1_3->new; |
|
| 158 | 158 |
is($dbi->user, 'ao', "$test : user"); |
| 159 | 159 |
is($dbi->database, 'ao', "$test : database"); |
| 160 | 160 |
is($dbi->password, 'bo', "$test : password"); |
| ... | ... |
@@ -166,11 +166,11 @@ is($dbi->bind_filter, 'fo', "$test : bind_filter"); |
| 166 | 166 |
is($dbi->fetch_filter, 'go', "$test : fetch_filter"); |
| 167 | 167 |
is($dbi->result_class, 'ho', "$test : result_class"); |
| 168 | 168 |
is($dbi->sql_template->tag_start, 1, "$test : sql_template"); |
| 169 |
-isa_ok($dbi, 'DBI::Custom::T1_3'); |
|
| 169 |
+isa_ok($dbi, 'DBIx::Custom::T1_3'); |
|
| 170 | 170 |
|
| 171 | 171 |
|
| 172 | 172 |
test 'Customized sub class constructor'; |
| 173 |
-$dbi = DBI::Custom::T1_3->new( |
|
| 173 |
+$dbi = DBIx::Custom::T1_3->new( |
|
| 174 | 174 |
user => 'a', |
| 175 | 175 |
database => 'a', |
| 176 | 176 |
password => 'b', |
| ... | ... |
@@ -198,16 +198,16 @@ is($dbi->bind_filter, 'f', "$test : bind_filter"); |
| 198 | 198 |
is($dbi->fetch_filter, 'g', "$test : fetch_filter"); |
| 199 | 199 |
is($dbi->result_class, 'h', "$test : result_class"); |
| 200 | 200 |
is($dbi->sql_template->tag_start, 2, "$test : sql_template"); |
| 201 |
-isa_ok($dbi, 'DBI::Custom'); |
|
| 201 |
+isa_ok($dbi, 'DBIx::Custom'); |
|
| 202 | 202 |
|
| 203 | 203 |
|
| 204 | 204 |
test 'add_filters'; |
| 205 |
-$dbi = DBI::Custom->new; |
|
| 205 |
+$dbi = DBIx::Custom->new; |
|
| 206 | 206 |
$dbi->add_filter(a => sub {1});
|
| 207 | 207 |
is($dbi->filters->{a}->(), 1, $test);
|
| 208 | 208 |
|
| 209 | 209 |
test 'add_formats'; |
| 210 |
-$dbi = DBI::Custom->new; |
|
| 210 |
+$dbi = DBIx::Custom->new; |
|
| 211 | 211 |
$dbi->add_format(a => sub {1});
|
| 212 | 212 |
is($dbi->formats->{a}->(), 1, $test);
|
| 213 | 213 |
|
| ... | ... |
@@ -9,7 +9,7 @@ BEGIN {
|
| 9 | 9 |
or plan skip_all => 'DBD::SQLite >= 1.00 required'; |
| 10 | 10 |
|
| 11 | 11 |
plan 'no_plan'; |
| 12 |
- use_ok('DBI::Custom');
|
|
| 12 |
+ use_ok('DBIx::Custom');
|
|
| 13 | 13 |
} |
| 14 | 14 |
|
| 15 | 15 |
# Function for test name |
| ... | ... |
@@ -59,21 +59,21 @@ my $ret_val; |
| 59 | 59 |
|
| 60 | 60 |
|
| 61 | 61 |
test 'disconnect'; |
| 62 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 62 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 63 | 63 |
$dbi->connect; |
| 64 | 64 |
$dbi->disconnect; |
| 65 | 65 |
ok(!$dbi->dbh, $test); |
| 66 | 66 |
|
| 67 | 67 |
|
| 68 | 68 |
test 'connected'; |
| 69 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 69 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 70 | 70 |
ok(!$dbi->connected, "$test : not connected"); |
| 71 | 71 |
$dbi->connect; |
| 72 | 72 |
ok($dbi->connected, "$test : connected"); |
| 73 | 73 |
|
| 74 | 74 |
|
| 75 | 75 |
test 'preapare'; |
| 76 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 76 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 77 | 77 |
$sth = $dbi->prepare($CREATE_TABLE->{0});
|
| 78 | 78 |
ok($sth, "$test : auto connect"); |
| 79 | 79 |
$sth->execute; |
| ... | ... |
@@ -82,7 +82,7 @@ ok($sth, "$test : basic"); |
| 82 | 82 |
|
| 83 | 83 |
|
| 84 | 84 |
test 'do'; |
| 85 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 85 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 86 | 86 |
$ret_val = $dbi->do($CREATE_TABLE->{0});
|
| 87 | 87 |
ok(defined $ret_val, "$test : auto connect"); |
| 88 | 88 |
$ret_val = $dbi->do($DROP_TABLE->{0});
|
| ... | ... |
@@ -90,7 +90,7 @@ ok(defined $ret_val, "$test : basic"); |
| 90 | 90 |
|
| 91 | 91 |
|
| 92 | 92 |
# Prepare table |
| 93 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 93 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 94 | 94 |
$dbi->connect; |
| 95 | 95 |
$dbi->do($CREATE_TABLE->{0});
|
| 96 | 96 |
$sth = $dbi->prepare("insert into table1 (key1, key2) values (?, ?);");
|
| ... | ... |
@@ -98,7 +98,7 @@ $sth->execute(1, 2); |
| 98 | 98 |
$sth->execute(3, 4); |
| 99 | 99 |
|
| 100 | 100 |
|
| 101 |
-test 'DBI::Custom::Result test'; |
|
| 101 |
+test 'DBIx::Custom::Result test'; |
|
| 102 | 102 |
$tmpl = "select key1, key2 from table1"; |
| 103 | 103 |
$query = $dbi->create_query($tmpl); |
| 104 | 104 |
$result = $dbi->execute($query); |
| ... | ... |
@@ -244,7 +244,7 @@ $rows = $result->fetch_all_hash; |
| 244 | 244 |
is_deeply($rows, [{key1 => 2, key2 => 4}], "$test : bind_filter");
|
| 245 | 245 |
|
| 246 | 246 |
|
| 247 |
-test 'DBI::Custom::SQL::Template basic tag'; |
|
| 247 |
+test 'DBIx::Custom::SQL::Template basic tag'; |
|
| 248 | 248 |
$dbi->do($DROP_TABLE->{0});
|
| 249 | 249 |
$dbi->do($CREATE_TABLE->{1});
|
| 250 | 250 |
$sth = $dbi->prepare("insert into table1 (key1, key2, key3, key4, key5) values (?, ?, ?, ?, ?);");
|
| ... | ... |
@@ -314,7 +314,7 @@ $rows = $result->fetch_all_hash; |
| 314 | 314 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : with table dot");
|
| 315 | 315 |
|
| 316 | 316 |
|
| 317 |
-test 'DBI::Custom::SQL::Template insert tag'; |
|
| 317 |
+test 'DBIx::Custom::SQL::Template insert tag'; |
|
| 318 | 318 |
$dbi->do("delete from table1");
|
| 319 | 319 |
$insert_tmpl = 'insert into table1 {insert key1 key2 key3 key4 key5}';
|
| 320 | 320 |
$dbi->execute($insert_tmpl, {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
| ... | ... |
@@ -356,7 +356,7 @@ $rows = $result->fetch_all_hash; |
| 356 | 356 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : #insert with table name dot");
|
| 357 | 357 |
|
| 358 | 358 |
|
| 359 |
-test 'DBI::Custom::SQL::Template update tag'; |
|
| 359 |
+test 'DBIx::Custom::SQL::Template update tag'; |
|
| 360 | 360 |
$dbi->do("delete from table1");
|
| 361 | 361 |
$insert_tmpl = "insert into table1 {insert key1 key2 key3 key4 key5}";
|
| 362 | 362 |
$dbi->execute($insert_tmpl, {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
| ... | ... |
@@ -434,36 +434,36 @@ is_deeply($rows, [], "$test : rollback"); |
| 434 | 434 |
|
| 435 | 435 |
|
| 436 | 436 |
test 'Error case'; |
| 437 |
-$dbi = DBI::Custom->new; |
|
| 437 |
+$dbi = DBIx::Custom->new; |
|
| 438 | 438 |
eval{$dbi->run_tranzaction};
|
| 439 | 439 |
like($@, qr/Not yet connect to database/, "$test : Yet Connected"); |
| 440 | 440 |
|
| 441 |
-$dbi = DBI::Custom->new(data_source => 'dbi:SQLit'); |
|
| 441 |
+$dbi = DBIx::Custom->new(data_source => 'dbi:SQLit'); |
|
| 442 | 442 |
eval{$dbi->connect;};
|
| 443 | 443 |
ok($@, "$test : connect error"); |
| 444 | 444 |
|
| 445 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 445 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 446 | 446 |
$dbi->connect; |
| 447 | 447 |
$dbi->dbh->{AutoCommit} = 0;
|
| 448 | 448 |
eval{$dbi->run_tranzaction()};
|
| 449 | 449 |
like($@, qr/AutoCommit must be true before tranzaction start/, |
| 450 | 450 |
"$test : run_tranzaction auto commit is false"); |
| 451 | 451 |
|
| 452 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 452 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 453 | 453 |
$sql = 'laksjdf'; |
| 454 | 454 |
eval{$dbi->prepare($sql)};
|
| 455 | 455 |
like($@, qr/$sql/, "$test : prepare fail"); |
| 456 | 456 |
|
| 457 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 457 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 458 | 458 |
$sql = 'laksjdf'; |
| 459 | 459 |
eval{$dbi->do($sql, qw/1 2 3/)};
|
| 460 | 460 |
like($@, qr/$sql/, "$test : do fail"); |
| 461 | 461 |
|
| 462 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 462 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 463 | 463 |
eval{$dbi->create_query("{p }")};
|
| 464 | 464 |
ok($@, "$test : create_query invalid SQL template"); |
| 465 | 465 |
|
| 466 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 466 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 467 | 467 |
$dbi->do($CREATE_TABLE->{0});
|
| 468 | 468 |
$query = $dbi->create_query("select * from table1 where {= key1}");
|
| 469 | 469 |
eval{$dbi->execute($query, {key2 => 1})};
|
| ... | ... |
@@ -472,7 +472,7 @@ like($@, qr/Corresponding key is not found in your parameters/, |
| 472 | 472 |
|
| 473 | 473 |
|
| 474 | 474 |
test 'insert'; |
| 475 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 475 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 476 | 476 |
$dbi->do($CREATE_TABLE->{0});
|
| 477 | 477 |
$dbi->insert('table1', {key1 => 1, key2 => 2});
|
| 478 | 478 |
$dbi->insert('table1', {key1 => 3, key2 => 4});
|
| ... | ... |
@@ -505,7 +505,7 @@ like($@, qr/Query edit callback must be code reference/, "$test : query edit cal |
| 505 | 505 |
|
| 506 | 506 |
|
| 507 | 507 |
test 'update'; |
| 508 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 508 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 509 | 509 |
$dbi->do($CREATE_TABLE->{1});
|
| 510 | 510 |
$dbi->insert('table1', {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
| 511 | 511 |
$dbi->insert('table1', {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
| ... | ... |
@@ -547,7 +547,7 @@ is_deeply($rows, [{key1 => 1, key2 => 22, key3 => 3, key4 => 4, key5 => 5},
|
| 547 | 547 |
|
| 548 | 548 |
|
| 549 | 549 |
test 'update error'; |
| 550 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 550 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 551 | 551 |
$dbi->do($CREATE_TABLE->{1});
|
| 552 | 552 |
eval{$dbi->update('table1')};
|
| 553 | 553 |
like($@, qr/Key-value pairs for update must be specified to 'update' second argument/, |
| ... | ... |
@@ -563,7 +563,7 @@ like($@, qr/Query edit callback must be code reference/, |
| 563 | 563 |
|
| 564 | 564 |
|
| 565 | 565 |
test 'update_all'; |
| 566 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 566 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 567 | 567 |
$dbi->do($CREATE_TABLE->{1});
|
| 568 | 568 |
$dbi->insert('table1', {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
| 569 | 569 |
$dbi->insert('table1', {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
| ... | ... |
@@ -582,7 +582,7 @@ is_deeply($rows, [{key1 => 1, key2 => 20, key3 => 3, key4 => 4, key5 => 5},
|
| 582 | 582 |
|
| 583 | 583 |
|
| 584 | 584 |
test 'delete'; |
| 585 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 585 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 586 | 586 |
$dbi->do($CREATE_TABLE->{0});
|
| 587 | 587 |
$dbi->insert('table1', {key1 => 1, key2 => 2});
|
| 588 | 588 |
$dbi->insert('table1', {key1 => 3, key2 => 4});
|
| ... | ... |
@@ -614,7 +614,7 @@ is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : delete multi key");
|
| 614 | 614 |
|
| 615 | 615 |
|
| 616 | 616 |
test 'delete error'; |
| 617 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 617 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 618 | 618 |
$dbi->do($CREATE_TABLE->{0});
|
| 619 | 619 |
eval{$dbi->delete('table1')};
|
| 620 | 620 |
like($@, qr/Key-value pairs for where clause must be specified to 'delete' second argument/, |
| ... | ... |
@@ -626,7 +626,7 @@ like($@, qr/Query edit callback must be code reference/, |
| 626 | 626 |
|
| 627 | 627 |
|
| 628 | 628 |
test 'delete_all'; |
| 629 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 629 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 630 | 630 |
$dbi->do($CREATE_TABLE->{0});
|
| 631 | 631 |
$dbi->insert('table1', {key1 => 1, key2 => 2});
|
| 632 | 632 |
$dbi->insert('table1', {key1 => 3, key2 => 4});
|
| ... | ... |
@@ -637,7 +637,7 @@ is_deeply($rows, [], "$test : basic"); |
| 637 | 637 |
|
| 638 | 638 |
|
| 639 | 639 |
test 'select'; |
| 640 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 640 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 641 | 641 |
$dbi->do($CREATE_TABLE->{0});
|
| 642 | 642 |
$dbi->insert('table1', {key1 => 1, key2 => 2});
|
| 643 | 643 |
$dbi->insert('table1', {key1 => 3, key2 => 4});
|
| ... | ... |
@@ -678,39 +678,39 @@ $rows = $dbi->select([qw/table1 table2/], |
| 678 | 678 |
is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "$test : join");
|
| 679 | 679 |
|
| 680 | 680 |
test 'Cache'; |
| 681 |
-$dbi = DBI::Custom->new($NEW_ARGS->{0});
|
|
| 682 |
-DBI::Custom->query_cache_max(2); |
|
| 681 |
+$dbi = DBIx::Custom->new($NEW_ARGS->{0});
|
|
| 682 |
+DBIx::Custom->query_cache_max(2); |
|
| 683 | 683 |
$dbi->do($CREATE_TABLE->{0});
|
| 684 |
-DBI::Custom->delete_class_attr('_query_caches');
|
|
| 685 |
-DBI::Custom->delete_class_attr('_query_cache_keys');
|
|
| 684 |
+DBIx::Custom->delete_class_attr('_query_caches');
|
|
| 685 |
+DBIx::Custom->delete_class_attr('_query_cache_keys');
|
|
| 686 | 686 |
$tmpls[0] = "insert into table1 {insert key1 key2}";
|
| 687 | 687 |
$queries[0] = $dbi->create_query($tmpls[0]); |
| 688 |
-is(DBI::Custom->_query_caches->{$tmpls[0]}{sql}, $queries[0]->sql, "$test : sql first");
|
|
| 689 |
-is(DBI::Custom->_query_caches->{$tmpls[0]}{key_infos}, $queries[0]->key_infos, "$test : key_infos first");
|
|
| 690 |
-is_deeply(DBI::Custom->_query_cache_keys, [@tmpls], "$test : cache key first"); |
|
| 688 |
+is(DBIx::Custom->_query_caches->{$tmpls[0]}{sql}, $queries[0]->sql, "$test : sql first");
|
|
| 689 |
+is(DBIx::Custom->_query_caches->{$tmpls[0]}{key_infos}, $queries[0]->key_infos, "$test : key_infos first");
|
|
| 690 |
+is_deeply(DBIx::Custom->_query_cache_keys, [@tmpls], "$test : cache key first"); |
|
| 691 | 691 |
|
| 692 | 692 |
$tmpls[1] = "select * from table1"; |
| 693 | 693 |
$queries[1] = $dbi->create_query($tmpls[1]); |
| 694 |
-is(DBI::Custom->_query_caches->{$tmpls[0]}{sql}, $queries[0]->sql, "$test : sql first");
|
|
| 695 |
-is(DBI::Custom->_query_caches->{$tmpls[0]}{key_infos}, $queries[0]->key_infos, "$test : key_infos first");
|
|
| 696 |
-is(DBI::Custom->_query_caches->{$tmpls[1]}{sql}, $queries[1]->sql, "$test : sql second");
|
|
| 697 |
-is(DBI::Custom->_query_caches->{$tmpls[1]}{key_infos}, $queries[1]->key_infos, "$test : key_infos second");
|
|
| 698 |
-is_deeply(DBI::Custom->_query_cache_keys, [@tmpls], "$test : cache key second"); |
|
| 694 |
+is(DBIx::Custom->_query_caches->{$tmpls[0]}{sql}, $queries[0]->sql, "$test : sql first");
|
|
| 695 |
+is(DBIx::Custom->_query_caches->{$tmpls[0]}{key_infos}, $queries[0]->key_infos, "$test : key_infos first");
|
|
| 696 |
+is(DBIx::Custom->_query_caches->{$tmpls[1]}{sql}, $queries[1]->sql, "$test : sql second");
|
|
| 697 |
+is(DBIx::Custom->_query_caches->{$tmpls[1]}{key_infos}, $queries[1]->key_infos, "$test : key_infos second");
|
|
| 698 |
+is_deeply(DBIx::Custom->_query_cache_keys, [@tmpls], "$test : cache key second"); |
|
| 699 | 699 |
|
| 700 | 700 |
$tmpls[2] = "select key1, key2 from table1"; |
| 701 | 701 |
$queries[2] = $dbi->create_query($tmpls[2]); |
| 702 |
-ok(!exists DBI::Custom->_query_caches->{$tmpls[0]}, "$test : cache overflow deleted key");
|
|
| 703 |
-is(DBI::Custom->_query_caches->{$tmpls[1]}{sql}, $queries[1]->sql, "$test : sql cache overflow deleted key");
|
|
| 704 |
-is(DBI::Custom->_query_caches->{$tmpls[1]}{key_infos}, $queries[1]->key_infos, "$test : key_infos cache overflow deleted key");
|
|
| 705 |
-is(DBI::Custom->_query_caches->{$tmpls[2]}{sql}, $queries[2]->sql, "$test : sql cache overflow deleted key");
|
|
| 706 |
-is(DBI::Custom->_query_caches->{$tmpls[2]}{key_infos}, $queries[2]->key_infos, "$test : key_infos cache overflow deleted key");
|
|
| 707 |
-is_deeply(DBI::Custom->_query_cache_keys, [@tmpls[1, 2]], "$test : cache key third"); |
|
| 702 |
+ok(!exists DBIx::Custom->_query_caches->{$tmpls[0]}, "$test : cache overflow deleted key");
|
|
| 703 |
+is(DBIx::Custom->_query_caches->{$tmpls[1]}{sql}, $queries[1]->sql, "$test : sql cache overflow deleted key");
|
|
| 704 |
+is(DBIx::Custom->_query_caches->{$tmpls[1]}{key_infos}, $queries[1]->key_infos, "$test : key_infos cache overflow deleted key");
|
|
| 705 |
+is(DBIx::Custom->_query_caches->{$tmpls[2]}{sql}, $queries[2]->sql, "$test : sql cache overflow deleted key");
|
|
| 706 |
+is(DBIx::Custom->_query_caches->{$tmpls[2]}{key_infos}, $queries[2]->key_infos, "$test : key_infos cache overflow deleted key");
|
|
| 707 |
+is_deeply(DBIx::Custom->_query_cache_keys, [@tmpls[1, 2]], "$test : cache key third"); |
|
| 708 | 708 |
|
| 709 | 709 |
$queries[1] = $dbi->create_query($tmpls[1]); |
| 710 |
-ok(!exists DBI::Custom->_query_caches->{$tmpls[0]}, "$test : cache overflow deleted key");
|
|
| 711 |
-is(DBI::Custom->_query_caches->{$tmpls[1]}{sql}, $queries[1]->sql, "$test : sql cache overflow deleted key");
|
|
| 712 |
-is(DBI::Custom->_query_caches->{$tmpls[1]}{key_infos}, $queries[1]->key_infos, "$test : key_infos cache overflow deleted key");
|
|
| 713 |
-is(DBI::Custom->_query_caches->{$tmpls[2]}{sql}, $queries[2]->sql, "$test : sql cache overflow deleted key");
|
|
| 714 |
-is(DBI::Custom->_query_caches->{$tmpls[2]}{key_infos}, $queries[2]->key_infos, "$test : key_infos cache overflow deleted key");
|
|
| 715 |
-is_deeply(DBI::Custom->_query_cache_keys, [@tmpls[1, 2]], "$test : cache key third"); |
|
| 710 |
+ok(!exists DBIx::Custom->_query_caches->{$tmpls[0]}, "$test : cache overflow deleted key");
|
|
| 711 |
+is(DBIx::Custom->_query_caches->{$tmpls[1]}{sql}, $queries[1]->sql, "$test : sql cache overflow deleted key");
|
|
| 712 |
+is(DBIx::Custom->_query_caches->{$tmpls[1]}{key_infos}, $queries[1]->key_infos, "$test : key_infos cache overflow deleted key");
|
|
| 713 |
+is(DBIx::Custom->_query_caches->{$tmpls[2]}{sql}, $queries[2]->sql, "$test : sql cache overflow deleted key");
|
|
| 714 |
+is(DBIx::Custom->_query_caches->{$tmpls[2]}{key_infos}, $queries[2]->key_infos, "$test : key_infos cache overflow deleted key");
|
|
| 715 |
+is_deeply(DBIx::Custom->_query_cache_keys, [@tmpls[1, 2]], "$test : cache key third"); |
|
| 716 | 716 |
|
| ... | ... |
@@ -9,10 +9,10 @@ plan skip_all => 'private MySQL test' unless $USER; |
| 9 | 9 |
|
| 10 | 10 |
plan 'no_plan'; |
| 11 | 11 |
|
| 12 |
-use DBI::Custom; |
|
| 12 |
+use DBIx::Custom; |
|
| 13 | 13 |
use Scalar::Util 'blessed'; |
| 14 | 14 |
{
|
| 15 |
- my $dbi = DBI::Custom->new( |
|
| 15 |
+ my $dbi = DBIx::Custom->new( |
|
| 16 | 16 |
user => $USER, |
| 17 | 17 |
password => $PASSWORD, |
| 18 | 18 |
data_source => "dbi:mysql:dbname=$DATABASE" |
| ... | ... |
@@ -46,6 +46,6 @@ sub module_boilerplate_ok {
|
| 46 | 46 |
"placeholder date/time" => qr(Date/time) |
| 47 | 47 |
); |
| 48 | 48 |
|
| 49 |
- module_boilerplate_ok('lib/DBI/Custom.pm');
|
|
| 49 |
+ module_boilerplate_ok('lib/DBIx/Custom.pm');
|
|
| 50 | 50 |
|
| 51 | 51 |
|