| ... | ... | 
                  @@ -20,8 +20,7 @@ __PACKAGE__->attr(  | 
              
| 20 | 20 | 
                  [qw/data_source dbh password user/],  | 
              
| 21 | 21 | 
                  cache => 1,  | 
              
| 22 | 22 | 
                       dbi_option => sub { {} },
                 | 
              
| 23 | 
                  - filter_check => 1,  | 
              |
| 24 | 
                  -    query_builder => sub {DBIx::Custom::QueryBuilder->new},
                 | 
              |
| 23 | 
                  +    query_builder => sub { DBIx::Custom::QueryBuilder->new },
                 | 
              |
| 25 | 24 | 
                  result_class => 'DBIx::Custom::Result',  | 
              
| 26 | 25 | 
                  table_class => 'DBIx::Custom::Table'  | 
              
| 27 | 26 | 
                  );  | 
              
| ... | ... | 
                  @@ -732,8 +731,10 @@ sub _croak {
                 | 
              
| 732 | 731 | 
                  }  | 
              
| 733 | 732 | 
                   | 
              
| 734 | 733 | 
                  # DEPRECATED!  | 
              
| 735 | 
                  -  | 
              |
| 736 | 
                  -__PACKAGE__->attr(dbi_options => sub { {} });
                 | 
              |
| 734 | 
                  +__PACKAGE__->attr(  | 
              |
| 735 | 
                  +    dbi_options => sub { {} },
                 | 
              |
| 736 | 
                  + filter_check => 1  | 
              |
| 737 | 
                  +);  | 
              |
| 737 | 738 | 
                   | 
              
| 738 | 739 | 
                   sub default_bind_filter {
                 | 
              
| 739 | 740 | 
                  my $self = shift;  | 
              
| ... | ... | 
                  @@ -5,7 +5,10 @@ use warnings;  | 
              
| 5 | 5 | 
                   | 
              
| 6 | 6 | 
                  use base 'Object::Simple';  | 
              
| 7 | 7 | 
                   | 
              
| 8 | 
                  -__PACKAGE__->attr([qw/columns default_filter filter sql sth/]);  | 
              |
| 8 | 
                  +__PACKAGE__->attr([qw/columns filter sql sth/]);  | 
              |
| 9 | 
                  +  | 
              |
| 10 | 
                  +# DEPRECATED!  | 
              |
| 11 | 
                  +__PACKAGE__->attr('default_filter');
                 | 
              |
| 9 | 12 | 
                   | 
              
| 10 | 13 | 
                  1;  | 
              
| 11 | 14 | 
                   | 
              
| ... | ... | 
                  @@ -26,18 +29,11 @@ DBIx::Custom::Query - Query  | 
              
| 26 | 29 | 
                   | 
              
| 27 | 30 | 
                  Column names.  | 
              
| 28 | 31 | 
                   | 
              
| 29 | 
                  -=head2 C<default_filter>  | 
              |
| 30 | 
                  -  | 
              |
| 31 | 
                  - my $default_filter = $query->default_filter;  | 
              |
| 32 | 
                  -    $query             = $query->default_filter('encode_utf8');
                 | 
              |
| 33 | 
                  -  | 
              |
| 34 | 
                  -Default filter when parameter binding is executed.  | 
              |
| 35 | 
                  -  | 
              |
| 36 | 32 | 
                  =head2 C<filter>  | 
              
| 37 | 33 | 
                   | 
              
| 38 | 34 | 
                  my $filter = $query->filter;  | 
              
| 39 | 
                  -    $query     = $query->filter({author => 'encode_utf8',
                 | 
              |
| 40 | 
                  - title => 'encode_utf8'});  | 
              |
| 35 | 
                  +    $query     = $query->filter({author => 'to_something',
                 | 
              |
| 36 | 
                  + title => 'to_something'});  | 
              |
| 41 | 37 | 
                   | 
              
| 42 | 38 | 
                  Filters when parameter binding is executed.  | 
              
| 43 | 39 | 
                  This overwrites C<default_filter>.  | 
              
| ... | ... | 
                  @@ -7,7 +7,7 @@ use base 'Object::Simple';  | 
              
| 7 | 7 | 
                   | 
              
| 8 | 8 | 
                  use Carp 'croak';  | 
              
| 9 | 9 | 
                  use DBIx::Custom::Query;  | 
              
| 10 | 
                  -use DBIx::Custom::QueryBuilder::TagProcessors;  | 
              |
| 10 | 
                  +use DBIx::Custom::TagProcessor;  | 
              |
| 11 | 11 | 
                   | 
              
| 12 | 12 | 
                  # Carp trust relationship  | 
              
| 13 | 13 | 
                  push @DBIx::Custom::CARP_NOT, __PACKAGE__;  | 
              
| ... | ... | 
                  @@ -17,17 +17,17 @@ push @DBIx::Custom::Where::CARP_NOT, __PACKAGE__;  | 
              
| 17 | 17 | 
                  # Attributes  | 
              
| 18 | 18 | 
                   __PACKAGE__->attr('tag_processors' => sub {
                 | 
              
| 19 | 19 | 
                       {
                 | 
              
| 20 | 
                  - '?' => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_placeholder_tag,  | 
              |
| 21 | 
                  - '=' => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_equal_tag,  | 
              |
| 22 | 
                  - '<>' => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_not_equal_tag,  | 
              |
| 23 | 
                  - '>' => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_greater_than_tag,  | 
              |
| 24 | 
                  - '<' => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_lower_than_tag,  | 
              |
| 25 | 
                  - '>=' => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_greater_than_equal_tag,  | 
              |
| 26 | 
                  - '<=' => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_lower_than_equal_tag,  | 
              |
| 27 | 
                  - 'like' => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_like_tag,  | 
              |
| 28 | 
                  - 'in' => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_in_tag,  | 
              |
| 29 | 
                  - 'insert_param' => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_insert_param_tag,  | 
              |
| 30 | 
                  - 'update_param' => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_update_param_tag  | 
              |
| 20 | 
                  + '?' => \&DBIx::Custom::TagProcessor::expand_placeholder_tag,  | 
              |
| 21 | 
                  + '=' => \&DBIx::Custom::TagProcessor::expand_equal_tag,  | 
              |
| 22 | 
                  + '<>' => \&DBIx::Custom::TagProcessor::expand_not_equal_tag,  | 
              |
| 23 | 
                  + '>' => \&DBIx::Custom::TagProcessor::expand_greater_than_tag,  | 
              |
| 24 | 
                  + '<' => \&DBIx::Custom::TagProcessor::expand_lower_than_tag,  | 
              |
| 25 | 
                  + '>=' => \&DBIx::Custom::TagProcessor::expand_greater_than_equal_tag,  | 
              |
| 26 | 
                  + '<=' => \&DBIx::Custom::TagProcessor::expand_lower_than_equal_tag,  | 
              |
| 27 | 
                  + 'like' => \&DBIx::Custom::TagProcessor::expand_like_tag,  | 
              |
| 28 | 
                  + 'in' => \&DBIx::Custom::TagProcessor::expand_in_tag,  | 
              |
| 29 | 
                  + 'insert_param' => \&DBIx::Custom::TagProcessor::expand_insert_param_tag,  | 
              |
| 30 | 
                  + 'update_param' => \&DBIx::Custom::TagProcessor::expand_update_param_tag  | 
              |
| 31 | 31 | 
                  }  | 
              
| 32 | 32 | 
                  });  | 
              
| 33 | 33 | 
                   | 
              
| ... | ... | 
                  @@ -1,179 +0,0 @@  | 
              
| 1 | 
                  -package DBIx::Custom::QueryBuilder::TagProcessors;  | 
              |
| 2 | 
                  -  | 
              |
| 3 | 
                  -use strict;  | 
              |
| 4 | 
                  -use warnings;  | 
              |
| 5 | 
                  -  | 
              |
| 6 | 
                  -use Carp 'croak';  | 
              |
| 7 | 
                  -  | 
              |
| 8 | 
                  -# Carp trust relationship  | 
              |
| 9 | 
                  -push @DBIx::Custom::QueryBuilder::CARP_NOT, __PACKAGE__;  | 
              |
| 10 | 
                  -  | 
              |
| 11 | 
                  -sub expand_equal_tag              { _expand_basic_tag('=',    @_) }
                 | 
              |
| 12 | 
                  -sub expand_greater_than_equal_tag { _expand_basic_tag('>=',   @_) }
                 | 
              |
| 13 | 
                  -sub expand_greater_than_tag       { _expand_basic_tag('>',    @_) }
                 | 
              |
| 14 | 
                  -  | 
              |
| 15 | 
                  -sub expand_in_tag {
                 | 
              |
| 16 | 
                  - my ($column, $count) = @_;  | 
              |
| 17 | 
                  -  | 
              |
| 18 | 
                  - # Check arguments  | 
              |
| 19 | 
                  -    croak qq{Column name and count of values must be specified in tag "{in }"}
                 | 
              |
| 20 | 
                  - unless $column && $count && $count =~ /^\d+$/;  | 
              |
| 21 | 
                  -  | 
              |
| 22 | 
                  - # Part of statement  | 
              |
| 23 | 
                  -    my $s = "$column in (";
                 | 
              |
| 24 | 
                  -    for (my $i = 0; $i < $count; $i++) {
                 | 
              |
| 25 | 
                  - $s .= '?, ';  | 
              |
| 26 | 
                  - }  | 
              |
| 27 | 
                  - $s =~ s/, $//;  | 
              |
| 28 | 
                  - $s .= ')';  | 
              |
| 29 | 
                  -  | 
              |
| 30 | 
                  - # Columns  | 
              |
| 31 | 
                  - my $columns = [];  | 
              |
| 32 | 
                  - push @$columns, $column for (0 .. $count - 1);  | 
              |
| 33 | 
                  -  | 
              |
| 34 | 
                  - return [$s, $columns];  | 
              |
| 35 | 
                  -}  | 
              |
| 36 | 
                  -  | 
              |
| 37 | 
                  -sub expand_insert_param_tag {
                 | 
              |
| 38 | 
                  - my @columns = @_;  | 
              |
| 39 | 
                  -  | 
              |
| 40 | 
                  - # Insert parameters  | 
              |
| 41 | 
                  -    my $s = '(';
                 | 
              |
| 42 | 
                  - $s .= "$_, " for @columns;  | 
              |
| 43 | 
                  - $s =~ s/, $//;  | 
              |
| 44 | 
                  - $s .= ') ';  | 
              |
| 45 | 
                  -    $s .= 'values (';
                 | 
              |
| 46 | 
                  - $s .= "?, " for @columns;  | 
              |
| 47 | 
                  - $s =~ s/, $//;  | 
              |
| 48 | 
                  - $s .= ')';  | 
              |
| 49 | 
                  -  | 
              |
| 50 | 
                  - return [$s, \@columns];  | 
              |
| 51 | 
                  -}  | 
              |
| 52 | 
                  -  | 
              |
| 53 | 
                  -sub expand_like_tag               { _expand_basic_tag('like', @_) }
                 | 
              |
| 54 | 
                  -sub expand_lower_than_equal_tag   { _expand_basic_tag('<=',   @_) }
                 | 
              |
| 55 | 
                  -sub expand_lower_than_tag         { _expand_basic_tag('<',    @_) }
                 | 
              |
| 56 | 
                  -sub expand_not_equal_tag          { _expand_basic_tag('<>',   @_) }
                 | 
              |
| 57 | 
                  -  | 
              |
| 58 | 
                  -sub expand_placeholder_tag {
                 | 
              |
| 59 | 
                  - my $column = shift;  | 
              |
| 60 | 
                  -  | 
              |
| 61 | 
                  - # Check arguments  | 
              |
| 62 | 
                  -    croak qq{Column name must be specified in tag "{? }"}
                 | 
              |
| 63 | 
                  - unless $column;  | 
              |
| 64 | 
                  -  | 
              |
| 65 | 
                  - return ['?', [$column]];  | 
              |
| 66 | 
                  -}  | 
              |
| 67 | 
                  -  | 
              |
| 68 | 
                  -sub expand_update_param_tag {
                 | 
              |
| 69 | 
                  - my @columns = @_;  | 
              |
| 70 | 
                  -  | 
              |
| 71 | 
                  - # Update paramters  | 
              |
| 72 | 
                  - my $s = 'set ';  | 
              |
| 73 | 
                  - $s .= "$_ = ?, " for @columns;  | 
              |
| 74 | 
                  - $s =~ s/, $//;  | 
              |
| 75 | 
                  -  | 
              |
| 76 | 
                  - return [$s, \@columns];  | 
              |
| 77 | 
                  -}  | 
              |
| 78 | 
                  -  | 
              |
| 79 | 
                  -sub _expand_basic_tag {
                 | 
              |
| 80 | 
                  - my ($name, $column) = @_;  | 
              |
| 81 | 
                  -  | 
              |
| 82 | 
                  - # Check arguments  | 
              |
| 83 | 
                  -    croak qq{Column name must be specified in tag "{$name }"}
                 | 
              |
| 84 | 
                  - unless $column;  | 
              |
| 85 | 
                  -  | 
              |
| 86 | 
                  - return ["$column $name ?", [$column]];  | 
              |
| 87 | 
                  -}  | 
              |
| 88 | 
                  -  | 
              |
| 89 | 
                  -1;  | 
              |
| 90 | 
                  -  | 
              |
| 91 | 
                  -=head1 NAME  | 
              |
| 92 | 
                  -  | 
              |
| 93 | 
                  -DBIx::Custom::QueryBuilder::TagProcessors - Tag processors  | 
              |
| 94 | 
                  -  | 
              |
| 95 | 
                  -=head1 SYNOPSYS  | 
              |
| 96 | 
                  -  | 
              |
| 97 | 
                  - my $expanded = expand_equal_tag($source);  | 
              |
| 98 | 
                  - my $expanded = expand_greater_than_equal_tag($source);  | 
              |
| 99 | 
                  - my $expanded = expand_greater_than_tag($source);  | 
              |
| 100 | 
                  - my $expanded = expand_like_tag($source);  | 
              |
| 101 | 
                  - my $expanded = expand_lower_than_equal_tag($source);  | 
              |
| 102 | 
                  - my $expanded = expand_lower_than_tag($source);  | 
              |
| 103 | 
                  - my $expanded = expand_in_tag($source);  | 
              |
| 104 | 
                  - my $expanded = expand_insert_param_tag($source);  | 
              |
| 105 | 
                  - my $expanded = expand_not_equal_tag($source);  | 
              |
| 106 | 
                  - my $expanded = expand_placeholder_tag($source);  | 
              |
| 107 | 
                  - my $expanded = expand_update_param_tag($source);  | 
              |
| 108 | 
                  -  | 
              |
| 109 | 
                  -=head1 TAG PROCESSORS  | 
              |
| 110 | 
                  -  | 
              |
| 111 | 
                  -Tag processor is function,  | 
              |
| 112 | 
                  -which receive arguments and return a part of SQL statment  | 
              |
| 113 | 
                  -and column names.  | 
              |
| 114 | 
                  -The part of SQL statment contains placeholders.  | 
              |
| 115 | 
                  -the count of placeholders must be  | 
              |
| 116 | 
                  -same as the count of column names.  | 
              |
| 117 | 
                  -  | 
              |
| 118 | 
                  -    sub processor_name {
                 | 
              |
| 119 | 
                  - my @args = @_;  | 
              |
| 120 | 
                  -  | 
              |
| 121 | 
                  - # Part of statment, which constains placeholders  | 
              |
| 122 | 
                  - my $s;  | 
              |
| 123 | 
                  -  | 
              |
| 124 | 
                  - # Column names  | 
              |
| 125 | 
                  - my $columns = [];  | 
              |
| 126 | 
                  -  | 
              |
| 127 | 
                  - # Do something  | 
              |
| 128 | 
                  - # ...  | 
              |
| 129 | 
                  -  | 
              |
| 130 | 
                  - return [$s, $columns];  | 
              |
| 131 | 
                  - }  | 
              |
| 132 | 
                  -  | 
              |
| 133 | 
                  -=head2 C<expand_equal_tag>  | 
              |
| 134 | 
                  -  | 
              |
| 135 | 
                  -    ('NAME')  ->  ['NAME = ?', ['NAME']]
                 | 
              |
| 136 | 
                  -  | 
              |
| 137 | 
                  -=head2 C<expand_greater_than_equal_tag>  | 
              |
| 138 | 
                  -  | 
              |
| 139 | 
                  -    ('NAME')  ->  ['NAME >= ?', ['NAME']]
                 | 
              |
| 140 | 
                  -  | 
              |
| 141 | 
                  -=head2 C<expand_greater_than_tag>  | 
              |
| 142 | 
                  -  | 
              |
| 143 | 
                  -    ('NAME')  ->  ['NAME > ?', ['NAME']]
                 | 
              |
| 144 | 
                  -  | 
              |
| 145 | 
                  -=head2 C<expand_like_tag>  | 
              |
| 146 | 
                  -  | 
              |
| 147 | 
                  -    ('NAME')  ->  ['NAME like ?', ['NAME']]
                 | 
              |
| 148 | 
                  -  | 
              |
| 149 | 
                  -=head2 C<expand_lower_than_equal_tag>  | 
              |
| 150 | 
                  -  | 
              |
| 151 | 
                  -    ('NAME')  ->  ['NAME <= ?', ['NAME']]
                 | 
              |
| 152 | 
                  -  | 
              |
| 153 | 
                  -=head2 C<expand_lower_than_tag>  | 
              |
| 154 | 
                  -  | 
              |
| 155 | 
                  -    ('NAME')  ->  ['NAME < ?', ['NAME']]
                 | 
              |
| 156 | 
                  -  | 
              |
| 157 | 
                  -=head2 C<expand_in_tag>  | 
              |
| 158 | 
                  -  | 
              |
| 159 | 
                  -    ('NAME', 3)  -> ['NAME in (?, ?, ?)', ['NAME', 'NAME', 'NAME']]
                 | 
              |
| 160 | 
                  -  | 
              |
| 161 | 
                  -=head2 C<expand_insert_param_tag>  | 
              |
| 162 | 
                  -  | 
              |
| 163 | 
                  -    ('NAME1', 'NAME2')
                 | 
              |
| 164 | 
                  - -> ['(NAME1, NAME2) values (?, ?, ?)', ['NAME1', 'NAME2']]  | 
              |
| 165 | 
                  -  | 
              |
| 166 | 
                  -=head2 C<expand_not_equal_tag>  | 
              |
| 167 | 
                  -  | 
              |
| 168 | 
                  -    ('NAME')  ->  ['NAME <> ?', ['NAME']]
                 | 
              |
| 169 | 
                  -  | 
              |
| 170 | 
                  -=head2 C<expand_placeholder_tag>  | 
              |
| 171 | 
                  -  | 
              |
| 172 | 
                  -    ('NAME')  ->  ['?', ['NAME']]
                 | 
              |
| 173 | 
                  -  | 
              |
| 174 | 
                  -=head2 C<expand_update_param_tag>  | 
              |
| 175 | 
                  -  | 
              |
| 176 | 
                  -    ('NAME1', 'NAME2')
                 | 
              |
| 177 | 
                  - -> ['set NAME1 = ?, NAME2 = ?', ['NAME1', 'NAME2']]  | 
              |
| 178 | 
                  -  | 
              |
| 179 | 
                  -=cut  | 
              
| ... | ... | 
                  @@ -7,7 +7,7 @@ use base 'Object::Simple';  | 
              
| 7 | 7 | 
                   | 
              
| 8 | 8 | 
                  use Carp 'croak';  | 
              
| 9 | 9 | 
                   | 
              
| 10 | 
                  -__PACKAGE__->attr([qw/filter_check filters sth/]);  | 
              |
| 10 | 
                  +__PACKAGE__->attr([qw/filters sth/]);  | 
              |
| 11 | 11 | 
                   | 
              
| 12 | 12 | 
                   sub filter {
                 | 
              
| 13 | 13 | 
                  my $self = shift;  | 
              
| ... | ... | 
                  @@ -239,6 +239,9 @@ sub default_filter {
                 | 
              
| 239 | 239 | 
                       return $self->{default_filter};
                 | 
              
| 240 | 240 | 
                  }  | 
              
| 241 | 241 | 
                   | 
              
| 242 | 
                  +# DEPRECATED!  | 
              |
| 243 | 
                  +__PACKAGE__->attr('filter_check'); 
                 | 
              |
| 244 | 
                  +  | 
              |
| 242 | 245 | 
                  1;  | 
              
| 243 | 246 | 
                   | 
              
| 244 | 247 | 
                  =head1 NAME  | 
              
| ... | ... | 
                  @@ -311,13 +314,6 @@ This overwrites C<default_filter>.  | 
              
| 311 | 314 | 
                   | 
              
| 312 | 315 | 
                  Resistered filters.  | 
              
| 313 | 316 | 
                   | 
              
| 314 | 
                  -=head2 C<filter_check>  | 
              |
| 315 | 
                  -  | 
              |
| 316 | 
                  - my $filter_check = $result->filter_check;  | 
              |
| 317 | 
                  - $result = $result->filter_check;  | 
              |
| 318 | 
                  -  | 
              |
| 319 | 
                  -Enable filter validation.  | 
              |
| 320 | 
                  -  | 
              |
| 321 | 317 | 
                  =head2 C<sth>  | 
              
| 322 | 318 | 
                   | 
              
| 323 | 319 | 
                  my $sth = $reuslt->sth  | 
              
| ... | ... | 
                  @@ -10,7 +10,7 @@ use Carp 'croak';  | 
              
| 10 | 10 | 
                  # Carp trust relationship  | 
              
| 11 | 11 | 
                  push @DBIx::Custom::CARP_NOT, __PACKAGE__;  | 
              
| 12 | 12 | 
                   | 
              
| 13 | 
                  -__PACKAGE__->attr(['dbi', 'name', 'model']);  | 
              |
| 13 | 
                  +__PACKAGE__->attr(['dbi', 'name']);  | 
              |
| 14 | 14 | 
                   | 
              
| 15 | 15 | 
                  our $AUTOLOAD;  | 
              
| 16 | 16 | 
                   | 
              
| ... | ... | 
                  @@ -0,0 +1,94 @@  | 
              
| 1 | 
                  +package DBIx::Custom::TagProcessor;  | 
              |
| 2 | 
                  +  | 
              |
| 3 | 
                  +use strict;  | 
              |
| 4 | 
                  +use warnings;  | 
              |
| 5 | 
                  +  | 
              |
| 6 | 
                  +use Carp 'croak';  | 
              |
| 7 | 
                  +  | 
              |
| 8 | 
                  +# Carp trust relationship  | 
              |
| 9 | 
                  +push @DBIx::Custom::QueryBuilder::CARP_NOT, __PACKAGE__;  | 
              |
| 10 | 
                  +  | 
              |
| 11 | 
                  +sub expand_equal_tag              { _expand_basic_tag('=',    @_) }
                 | 
              |
| 12 | 
                  +sub expand_greater_than_equal_tag { _expand_basic_tag('>=',   @_) }
                 | 
              |
| 13 | 
                  +sub expand_greater_than_tag       { _expand_basic_tag('>',    @_) }
                 | 
              |
| 14 | 
                  +  | 
              |
| 15 | 
                  +sub expand_in_tag {
                 | 
              |
| 16 | 
                  + my ($column, $count) = @_;  | 
              |
| 17 | 
                  +  | 
              |
| 18 | 
                  + # Check arguments  | 
              |
| 19 | 
                  +    croak qq{Column name and count of values must be specified in tag "{in }"}
                 | 
              |
| 20 | 
                  + unless $column && $count && $count =~ /^\d+$/;  | 
              |
| 21 | 
                  +  | 
              |
| 22 | 
                  + # Part of statement  | 
              |
| 23 | 
                  +    my $s = "$column in (";
                 | 
              |
| 24 | 
                  +    for (my $i = 0; $i < $count; $i++) {
                 | 
              |
| 25 | 
                  + $s .= '?, ';  | 
              |
| 26 | 
                  + }  | 
              |
| 27 | 
                  + $s =~ s/, $//;  | 
              |
| 28 | 
                  + $s .= ')';  | 
              |
| 29 | 
                  +  | 
              |
| 30 | 
                  + # Columns  | 
              |
| 31 | 
                  + my $columns = [];  | 
              |
| 32 | 
                  + push @$columns, $column for (0 .. $count - 1);  | 
              |
| 33 | 
                  +  | 
              |
| 34 | 
                  + return [$s, $columns];  | 
              |
| 35 | 
                  +}  | 
              |
| 36 | 
                  +  | 
              |
| 37 | 
                  +sub expand_insert_param_tag {
                 | 
              |
| 38 | 
                  + my @columns = @_;  | 
              |
| 39 | 
                  +  | 
              |
| 40 | 
                  + # Insert parameters  | 
              |
| 41 | 
                  +    my $s = '(';
                 | 
              |
| 42 | 
                  + $s .= "$_, " for @columns;  | 
              |
| 43 | 
                  + $s =~ s/, $//;  | 
              |
| 44 | 
                  + $s .= ') ';  | 
              |
| 45 | 
                  +    $s .= 'values (';
                 | 
              |
| 46 | 
                  + $s .= "?, " for @columns;  | 
              |
| 47 | 
                  + $s =~ s/, $//;  | 
              |
| 48 | 
                  + $s .= ')';  | 
              |
| 49 | 
                  +  | 
              |
| 50 | 
                  + return [$s, \@columns];  | 
              |
| 51 | 
                  +}  | 
              |
| 52 | 
                  +  | 
              |
| 53 | 
                  +sub expand_like_tag               { _expand_basic_tag('like', @_) }
                 | 
              |
| 54 | 
                  +sub expand_lower_than_equal_tag   { _expand_basic_tag('<=',   @_) }
                 | 
              |
| 55 | 
                  +sub expand_lower_than_tag         { _expand_basic_tag('<',    @_) }
                 | 
              |
| 56 | 
                  +sub expand_not_equal_tag          { _expand_basic_tag('<>',   @_) }
                 | 
              |
| 57 | 
                  +  | 
              |
| 58 | 
                  +sub expand_placeholder_tag {
                 | 
              |
| 59 | 
                  + my $column = shift;  | 
              |
| 60 | 
                  +  | 
              |
| 61 | 
                  + # Check arguments  | 
              |
| 62 | 
                  +    croak qq{Column name must be specified in tag "{? }"}
                 | 
              |
| 63 | 
                  + unless $column;  | 
              |
| 64 | 
                  +  | 
              |
| 65 | 
                  + return ['?', [$column]];  | 
              |
| 66 | 
                  +}  | 
              |
| 67 | 
                  +  | 
              |
| 68 | 
                  +sub expand_update_param_tag {
                 | 
              |
| 69 | 
                  + my @columns = @_;  | 
              |
| 70 | 
                  +  | 
              |
| 71 | 
                  + # Update paramters  | 
              |
| 72 | 
                  + my $s = 'set ';  | 
              |
| 73 | 
                  + $s .= "$_ = ?, " for @columns;  | 
              |
| 74 | 
                  + $s =~ s/, $//;  | 
              |
| 75 | 
                  +  | 
              |
| 76 | 
                  + return [$s, \@columns];  | 
              |
| 77 | 
                  +}  | 
              |
| 78 | 
                  +  | 
              |
| 79 | 
                  +sub _expand_basic_tag {
                 | 
              |
| 80 | 
                  + my ($name, $column) = @_;  | 
              |
| 81 | 
                  +  | 
              |
| 82 | 
                  + # Check arguments  | 
              |
| 83 | 
                  +    croak qq{Column name must be specified in tag "{$name }"}
                 | 
              |
| 84 | 
                  + unless $column;  | 
              |
| 85 | 
                  +  | 
              |
| 86 | 
                  + return ["$column $name ?", [$column]];  | 
              |
| 87 | 
                  +}  | 
              |
| 88 | 
                  +  | 
              |
| 89 | 
                  +1;  | 
              |
| 90 | 
                  +  | 
              |
| 91 | 
                  +=head1 NAME  | 
              |
| 92 | 
                  +  | 
              |
| 93 | 
                  +DBIx::Custom::TagProcessor - Tag processor  | 
              |
| 94 | 
                  +  | 
              
| ... | ... | 
                  @@ -16,10 +16,7 @@ BEGIN {
                 | 
              
| 16 | 16 | 
                  }  | 
              
| 17 | 17 | 
                   | 
              
| 18 | 18 | 
                  # Function for test name  | 
              
| 19 | 
                  -my $test;  | 
              |
| 20 | 
                  -sub test {
                 | 
              |
| 21 | 
                  - $test = shift;  | 
              |
| 22 | 
                  -}  | 
              |
| 19 | 
                  +sub test { "# $_[0]\n" }
                 | 
              |
| 23 | 20 | 
                   | 
              
| 24 | 21 | 
                  # Constant varialbes for test  | 
              
| 25 | 22 | 
                   my $CREATE_TABLE = {
                 | 
              
| ... | ... | 
                  @@ -80,22 +77,22 @@ $result = $dbi->execute($query);  | 
              
| 80 | 77 | 
                   while (my $row = $result->fetch) {
                 | 
              
| 81 | 78 | 
                  push @rows, [@$row];  | 
              
| 82 | 79 | 
                  }  | 
              
| 83 | 
                  -is_deeply(\@rows, [[1, 2], [3, 4]], "$test : fetch");  | 
              |
| 80 | 
                  +is_deeply(\@rows, [[1, 2], [3, 4]], "fetch");  | 
              |
| 84 | 81 | 
                   | 
              
| 85 | 82 | 
                  $result = $dbi->execute($query);  | 
              
| 86 | 83 | 
                  @rows = ();  | 
              
| 87 | 84 | 
                   while (my $row = $result->fetch_hash) {
                 | 
              
| 88 | 85 | 
                       push @rows, {%$row};
                 | 
              
| 89 | 86 | 
                  }  | 
              
| 90 | 
                  -is_deeply(\@rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "$test : fetch_hash");
                 | 
              |
| 87 | 
                  +is_deeply(\@rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "fetch_hash");
                 | 
              |
| 91 | 88 | 
                   | 
              
| 92 | 89 | 
                  $result = $dbi->execute($query);  | 
              
| 93 | 90 | 
                  $rows = $result->fetch_all;  | 
              
| 94 | 
                  -is_deeply($rows, [[1, 2], [3, 4]], "$test : fetch_all");  | 
              |
| 91 | 
                  +is_deeply($rows, [[1, 2], [3, 4]], "fetch_all");  | 
              |
| 95 | 92 | 
                   | 
              
| 96 | 93 | 
                  $result = $dbi->execute($query);  | 
              
| 97 | 94 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 98 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "$test : fetch_hash_all");
                 | 
              |
| 95 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "fetch_hash_all");
                 | 
              |
| 99 | 96 | 
                   | 
              
| 100 | 97 | 
                  test 'Insert query return value';  | 
              
| 101 | 98 | 
                   $dbi->execute($DROP_TABLE->{0});
                 | 
              
| ... | ... | 
                  @@ -103,7 +100,7 @@ $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 103 | 100 | 
                   $source = "insert into table1 {insert_param key1 key2}";
                 | 
              
| 104 | 101 | 
                  $query = $dbi->create_query($source);  | 
              
| 105 | 102 | 
                   $ret_val = $dbi->execute($query, param => {key1 => 1, key2 => 2});
                 | 
              
| 106 | 
                  -ok($ret_val, $test);  | 
              |
| 103 | 
                  +ok($ret_val);  | 
              |
| 107 | 104 | 
                   | 
              
| 108 | 105 | 
                   | 
              
| 109 | 106 | 
                  test 'Direct query';  | 
              
| ... | ... | 
                  @@ -113,7 +110,7 @@ $insert_SOURCE = "insert into table1 {insert_param key1 key2}";
                 | 
              
| 113 | 110 | 
                   $dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2});
                 | 
              
| 114 | 111 | 
                   $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 115 | 112 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 116 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2}], $test);
                 | 
              |
| 113 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2}]);
                 | 
              |
| 117 | 114 | 
                   | 
              
| 118 | 115 | 
                  test 'Filter basic';  | 
              
| 119 | 116 | 
                   $dbi->execute($DROP_TABLE->{0});
                 | 
              
| ... | ... | 
                  @@ -127,7 +124,7 @@ $insert_query->filter({key1 => 'twice'});
                 | 
              
| 127 | 124 | 
                   $dbi->execute($insert_query, param => {key1 => 1, key2 => 2});
                 | 
              
| 128 | 125 | 
                   $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 129 | 126 | 
                   $rows = $result->filter({key2 => 'three_times'})->fetch_hash_all;
                 | 
              
| 130 | 
                  -is_deeply($rows, [{key1 => 2, key2 => 6}], "$test : filter fetch_filter");
                 | 
              |
| 127 | 
                  +is_deeply($rows, [{key1 => 2, key2 => 6}], "filter fetch_filter");
                 | 
              |
| 131 | 128 | 
                   $dbi->execute($DROP_TABLE->{0});
                 | 
              
| 132 | 129 | 
                   | 
              
| 133 | 130 | 
                  test 'Filter in';  | 
              
| ... | ... | 
                  @@ -140,7 +137,7 @@ $select_query = $dbi->create_query($select_SOURCE);  | 
              
| 140 | 137 | 
                   $select_query->filter({'table1.key1' => 'twice'});
                 | 
              
| 141 | 138 | 
                   $result = $dbi->execute($select_query, param => {'table1.key1' => [1,5], 'table1.key2' => [2,4]});
                 | 
              
| 142 | 139 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 143 | 
                  -is_deeply($rows, [{key1 => 2, key2 => 4}], "$test : filter");
                 | 
              |
| 140 | 
                  +is_deeply($rows, [{key1 => 2, key2 => 4}], "filter");
                 | 
              |
| 144 | 141 | 
                   | 
              
| 145 | 142 | 
                  test 'DBIx::Custom::SQLTemplate basic tag';  | 
              
| 146 | 143 | 
                   $dbi->execute($DROP_TABLE->{0});
                 | 
              
| ... | ... | 
                  @@ -152,13 +149,13 @@ $source = "select * from table1 where {= key1} and {<> key2} and {< key3} and {>
                 | 
              
| 152 | 149 | 
                  $query = $dbi->create_query($source);  | 
              
| 153 | 150 | 
                   $result = $dbi->execute($query, param => {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key5 => 5});
                 | 
              
| 154 | 151 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 155 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag1");
                 | 
              |
| 152 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic tag1");
                 | 
              |
| 156 | 153 | 
                   | 
              
| 157 | 154 | 
                   $source = "select * from table1 where {<= key1} and {like key2};";
                 | 
              
| 158 | 155 | 
                  $query = $dbi->create_query($source);  | 
              
| 159 | 156 | 
                   $result = $dbi->execute($query, param => {key1 => 1, key2 => '%2%'});
                 | 
              
| 160 | 157 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 161 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag2");
                 | 
              |
| 158 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic tag2");
                 | 
              |
| 162 | 159 | 
                   | 
              
| 163 | 160 | 
                  test 'DIB::Custom::SQLTemplate in tag';  | 
              
| 164 | 161 | 
                   $dbi->execute($DROP_TABLE->{0});
                 | 
              
| ... | ... | 
                  @@ -170,7 +167,7 @@ $source = "select * from table1 where {in key1 2};";
                 | 
              
| 170 | 167 | 
                  $query = $dbi->create_query($source);  | 
              
| 171 | 168 | 
                   $result = $dbi->execute($query, param => {key1 => [9, 1]});
                 | 
              
| 172 | 169 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 173 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic");
                 | 
              |
| 170 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic");
                 | 
              |
| 174 | 171 | 
                   | 
              
| 175 | 172 | 
                  test 'DBIx::Custom::SQLTemplate insert tag';  | 
              
| 176 | 173 | 
                   $dbi->execute("delete from table1");
                 | 
              
| ... | ... | 
                  @@ -179,7 +176,7 @@ $dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2, key3 => 3, key4 =>
                 | 
              
| 179 | 176 | 
                   | 
              
| 180 | 177 | 
                   $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 181 | 178 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 182 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic");
                 | 
              |
| 179 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic");
                 | 
              |
| 183 | 180 | 
                   | 
              
| 184 | 181 | 
                  test 'DBIx::Custom::SQLTemplate update tag';  | 
              
| 185 | 182 | 
                   $dbi->execute("delete from table1");
                 | 
              
| ... | ... | 
                  @@ -193,15 +190,15 @@ $dbi->execute($update_SOURCE, param => {key1 => 1, key2 => 1, key3 => 1, key4 =>
                 | 
              
| 193 | 190 | 
                   $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 194 | 191 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 195 | 192 | 
                   is_deeply($rows, [{key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5},
                 | 
              
| 196 | 
                  -                  {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : basic");
                 | 
              |
| 193 | 
                  +                  {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "basic");
                 | 
              |
| 197 | 194 | 
                   | 
              
| 198 | 195 | 
                  test 'Error case';  | 
              
| 199 | 196 | 
                   eval {DBIx::Custom->connect(data_source => 'dbi:SQLit')};
                 | 
              
| 200 | 
                  -ok($@, "$test : connect error");  | 
              |
| 197 | 
                  +ok($@, "connect error");  | 
              |
| 201 | 198 | 
                   | 
              
| 202 | 199 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| 203 | 200 | 
                   eval{$dbi->create_query("{p }")};
                 | 
              
| 204 | 
                  -ok($@, "$test : create_query invalid SQL template");  | 
              |
| 201 | 
                  +ok($@, "create_query invalid SQL template");  | 
              |
| 205 | 202 | 
                   | 
              
| 206 | 203 | 
                  test 'insert';  | 
              
| 207 | 204 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| ... | ... | 
                  @@ -210,7 +207,7 @@ $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              
| 210 | 207 | 
                   $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
                 | 
              
| 211 | 208 | 
                   $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 212 | 209 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 213 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "$test : basic");
                 | 
              |
| 210 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
                 | 
              |
| 214 | 211 | 
                   | 
              
| 215 | 212 | 
                   $dbi->execute('delete from table1');
                 | 
              
| 216 | 213 | 
                  $dbi->register_filter(  | 
              
| ... | ... | 
                  @@ -221,7 +218,7 @@ $dbi->default_bind_filter('twice');
                 | 
              
| 221 | 218 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, filter => {key1 => 'three_times'});
                 | 
              
| 222 | 219 | 
                   $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 223 | 220 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 224 | 
                  -is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : filter");
                 | 
              |
| 221 | 
                  +is_deeply($rows, [{key1 => 3, key2 => 4}], "filter");
                 | 
              |
| 225 | 222 | 
                  $dbi->default_bind_filter(undef);  | 
              
| 226 | 223 | 
                   | 
              
| 227 | 224 | 
                   $dbi->execute($DROP_TABLE->{0});
                 | 
              
| ... | ... | 
                  @@ -231,7 +228,7 @@ $rows = $dbi->select(table => 'table1')->fetch_hash_all;  | 
              
| 231 | 228 | 
                   is_deeply($rows, [{key1 => 1, key2 => 2}], 'insert append');
                 | 
              
| 232 | 229 | 
                   | 
              
| 233 | 230 | 
                   eval{$dbi->insert(table => 'table1', noexist => 1)};
                 | 
              
| 234 | 
                  -like($@, qr/noexist/, "$test: invalid argument");  | 
              |
| 231 | 
                  +like($@, qr/noexist/, "invalid argument");  | 
              |
| 235 | 232 | 
                   | 
              
| 236 | 233 | 
                   | 
              
| 237 | 234 | 
                  test 'update';  | 
              
| ... | ... | 
                  @@ -244,7 +241,7 @@ $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 244 | 241 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 245 | 242 | 
                   is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
                 | 
              
| 246 | 243 | 
                                     {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
                 | 
              
| 247 | 
                  - "$test : basic");  | 
              |
| 244 | 
                  + "basic");  | 
              |
| 248 | 245 | 
                   | 
              
| 249 | 246 | 
                   $dbi->execute("delete from table1");
                 | 
              
| 250 | 247 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
                 | 
              
| ... | ... | 
                  @@ -254,14 +251,14 @@ $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 254 | 251 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 255 | 252 | 
                   is_deeply($rows, [{key1 => 1, key2 => 12, key3 => 3, key4 => 4, key5 => 5},
                 | 
              
| 256 | 253 | 
                                     {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
                 | 
              
| 257 | 
                  - "$test : update key same as search key");  | 
              |
| 254 | 
                  + "update key same as search key");  | 
              |
| 258 | 255 | 
                   | 
              
| 259 | 256 | 
                   $dbi->update(table => 'table1', param => {key2 => [12]}, where => {key2 => 2, key3 => 3});
                 | 
              
| 260 | 257 | 
                   $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 261 | 258 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 262 | 259 | 
                   is_deeply($rows, [{key1 => 1, key2 => 12, key3 => 3, key4 => 4, key5 => 5},
                 | 
              
| 263 | 260 | 
                                     {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
                 | 
              
| 264 | 
                  - "$test : update key same as search key : param is array ref");  | 
              |
| 261 | 
                  + "update key same as search key : param is array ref");  | 
              |
| 265 | 262 | 
                   | 
              
| 266 | 263 | 
                   $dbi->execute("delete from table1");
                 | 
              
| 267 | 264 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
                 | 
              
| ... | ... | 
                  @@ -273,15 +270,15 @@ $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 273 | 270 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 274 | 271 | 
                   is_deeply($rows, [{key1 => 1, key2 => 22, key3 => 3, key4 => 4, key5 => 5},
                 | 
              
| 275 | 272 | 
                                     {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
                 | 
              
| 276 | 
                  - "$test : filter");  | 
              |
| 273 | 
                  + "filter");  | 
              |
| 277 | 274 | 
                   | 
              
| 278 | 275 | 
                   $result = $dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1}, append => '   ');
                 | 
              
| 279 | 276 | 
                   | 
              
| 280 | 277 | 
                   eval{$dbi->update(table => 'table1', noexist => 1)};
                 | 
              
| 281 | 
                  -like($@, qr/noexist/, "$test: invalid argument");  | 
              |
| 278 | 
                  +like($@, qr/noexist/, "invalid argument");  | 
              |
| 282 | 279 | 
                   | 
              
| 283 | 280 | 
                   eval{$dbi->update(table => 'table1')};
                 | 
              
| 284 | 
                  -like($@, qr/where/, "$test: not contain where");  | 
              |
| 281 | 
                  +like($@, qr/where/, "not contain where");  | 
              |
| 285 | 282 | 
                   | 
              
| 286 | 283 | 
                   | 
              
| 287 | 284 | 
                  test 'update_all';  | 
              
| ... | ... | 
                  @@ -295,7 +292,7 @@ $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 295 | 292 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 296 | 293 | 
                   is_deeply($rows, [{key1 => 1, key2 => 20, key3 => 3, key4 => 4, key5 => 5},
                 | 
              
| 297 | 294 | 
                                     {key1 => 6, key2 => 20, key3 => 8, key4 => 9, key5 => 10}],
                 | 
              
| 298 | 
                  - "$test : filter");  | 
              |
| 295 | 
                  + "filter");  | 
              |
| 299 | 296 | 
                   | 
              
| 300 | 297 | 
                   | 
              
| 301 | 298 | 
                  test 'delete';  | 
              
| ... | ... | 
                  @@ -306,7 +303,7 @@ $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
                 | 
              
| 306 | 303 | 
                   $dbi->delete(table => 'table1', where => {key1 => 1});
                 | 
              
| 307 | 304 | 
                   $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 308 | 305 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 309 | 
                  -is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : basic");
                 | 
              |
| 306 | 
                  +is_deeply($rows, [{key1 => 3, key2 => 4}], "basic");
                 | 
              |
| 310 | 307 | 
                   | 
              
| 311 | 308 | 
                   $dbi->execute("delete from table1;");
                 | 
              
| 312 | 309 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              
| ... | ... | 
                  @@ -315,7 +312,7 @@ $dbi->register_filter(twice => sub { $_[0] * 2 });
                 | 
              
| 315 | 312 | 
                   $dbi->delete(table => 'table1', where => {key2 => 1}, filter => {key2 => 'twice'});
                 | 
              
| 316 | 313 | 
                   $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 317 | 314 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 318 | 
                  -is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : filter");
                 | 
              |
| 315 | 
                  +is_deeply($rows, [{key1 => 3, key2 => 4}], "filter");
                 | 
              |
| 319 | 316 | 
                   | 
              
| 320 | 317 | 
                   $dbi->delete(table => 'table1', where => {key1 => 1}, append => '   ');
                 | 
              
| 321 | 318 | 
                   | 
              
| ... | ... | 
                  @@ -324,10 +321,10 @@ $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              
| 324 | 321 | 
                   $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
                 | 
              
| 325 | 322 | 
                   $dbi->delete(table => 'table1', where => {key1 => 1, key2 => 2});
                 | 
              
| 326 | 323 | 
                  $rows = $dbi->select(table => 'table1')->fetch_hash_all;  | 
              
| 327 | 
                  -is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : delete multi key");
                 | 
              |
| 324 | 
                  +is_deeply($rows, [{key1 => 3, key2 => 4}], "delete multi key");
                 | 
              |
| 328 | 325 | 
                   | 
              
| 329 | 326 | 
                   eval{$dbi->delete(table => 'table1', noexist => 1)};
                 | 
              
| 330 | 
                  -like($@, qr/noexist/, "$test: invalid argument");  | 
              |
| 327 | 
                  +like($@, qr/noexist/, "invalid argument");  | 
              |
| 331 | 328 | 
                   | 
              
| 332 | 329 | 
                   | 
              
| 333 | 330 | 
                  test 'delete error';  | 
              
| ... | ... | 
                  @@ -335,7 +332,7 @@ $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| 335 | 332 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 336 | 333 | 
                   eval{$dbi->delete(table => 'table1')};
                 | 
              
| 337 | 334 | 
                  like($@, qr/"where" argument must be specified and contains the pairs of column name and value/,  | 
              
| 338 | 
                  - "$test : where key-value pairs not specified");  | 
              |
| 335 | 
                  + "where key-value pairs not specified");  | 
              |
| 339 | 336 | 
                   | 
              
| 340 | 337 | 
                  test 'delete_all';  | 
              
| 341 | 338 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| ... | ... | 
                  @@ -345,7 +342,7 @@ $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
                 | 
              
| 345 | 342 | 
                  $dbi->delete_all(table => 'table1');  | 
              
| 346 | 343 | 
                   $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 347 | 344 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 348 | 
                  -is_deeply($rows, [], "$test : basic");  | 
              |
| 345 | 
                  +is_deeply($rows, [], "basic");  | 
              |
| 349 | 346 | 
                   | 
              
| 350 | 347 | 
                   | 
              
| 351 | 348 | 
                  test 'select';  | 
              
| ... | ... | 
                  @@ -355,27 +352,27 @@ $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              
| 355 | 352 | 
                   $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
                 | 
              
| 356 | 353 | 
                  $rows = $dbi->select(table => 'table1')->fetch_hash_all;  | 
              
| 357 | 354 | 
                   is_deeply($rows, [{key1 => 1, key2 => 2},
                 | 
              
| 358 | 
                  -                  {key1 => 3, key2 => 4}], "$test : table");
                 | 
              |
| 355 | 
                  +                  {key1 => 3, key2 => 4}], "table");
                 | 
              |
| 359 | 356 | 
                   | 
              
| 360 | 357 | 
                  $rows = $dbi->select(table => 'table1', column => ['key1'])->fetch_hash_all;  | 
              
| 361 | 
                  -is_deeply($rows, [{key1 => 1}, {key1 => 3}], "$test : table and columns and where key");
                 | 
              |
| 358 | 
                  +is_deeply($rows, [{key1 => 1}, {key1 => 3}], "table and columns and where key");
                 | 
              |
| 362 | 359 | 
                   | 
              
| 363 | 360 | 
                   $rows = $dbi->select(table => 'table1', where => {key1 => 1})->fetch_hash_all;
                 | 
              
| 364 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2}], "$test : table and columns and where key");
                 | 
              |
| 361 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2}], "table and columns and where key");
                 | 
              |
| 365 | 362 | 
                   | 
              
| 366 | 363 | 
                   $rows = $dbi->select(table => 'table1', where => ['{= key1} and {= key2}', {key1 => 1, key2 => 2}])->fetch_hash_all;
                 | 
              
| 367 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2}], "$test : table and columns and where string");
                 | 
              |
| 364 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2}], "table and columns and where string");
                 | 
              |
| 368 | 365 | 
                   | 
              
| 369 | 366 | 
                   $rows = $dbi->select(table => 'table1', column => ['key1'], where => {key1 => 3})->fetch_hash_all;
                 | 
              
| 370 | 
                  -is_deeply($rows, [{key1 => 3}], "$test : table and columns and where key");
                 | 
              |
| 367 | 
                  +is_deeply($rows, [{key1 => 3}], "table and columns and where key");
                 | 
              |
| 371 | 368 | 
                   | 
              
| 372 | 369 | 
                  $rows = $dbi->select(table => 'table1', append => "order by key1 desc limit 1")->fetch_hash_all;  | 
              
| 373 | 
                  -is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : append statement");
                 | 
              |
| 370 | 
                  +is_deeply($rows, [{key1 => 3, key2 => 4}], "append statement");
                 | 
              |
| 374 | 371 | 
                   | 
              
| 375 | 372 | 
                   $dbi->register_filter(decrement => sub { $_[0] - 1 });
                 | 
              
| 376 | 373 | 
                   $rows = $dbi->select(table => 'table1', where => {key1 => 2}, filter => {key1 => 'decrement'})
                 | 
              
| 377 | 374 | 
                  ->fetch_hash_all;  | 
              
| 378 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2}], "$test : filter");
                 | 
              |
| 375 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2}], "filter");
                 | 
              |
| 379 | 376 | 
                   | 
              
| 380 | 377 | 
                   $dbi->execute($CREATE_TABLE->{2});
                 | 
              
| 381 | 378 | 
                   $dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5});
                 | 
              
| ... | ... | 
                  @@ -385,17 +382,17 @@ $rows = $dbi->select(  | 
              
| 385 | 382 | 
                       where   => {'table1.key2' => 2},
                 | 
              
| 386 | 383 | 
                       relation  => {'table1.key1' => 'table2.key1'}
                 | 
              
| 387 | 384 | 
                  )->fetch_hash_all;  | 
              
| 388 | 
                  -is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "$test : relation : exists where");
                 | 
              |
| 385 | 
                  +is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "relation : exists where");
                 | 
              |
| 389 | 386 | 
                   | 
              
| 390 | 387 | 
                  $rows = $dbi->select(  | 
              
| 391 | 388 | 
                  table => [qw/table1 table2/],  | 
              
| 392 | 389 | 
                  column => ['table1.key1 as table1_key1', 'table2.key1 as table2_key1', 'key2', 'key3'],  | 
              
| 393 | 390 | 
                       relation  => {'table1.key1' => 'table2.key1'}
                 | 
              
| 394 | 391 | 
                  )->fetch_hash_all;  | 
              
| 395 | 
                  -is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "$test : relation : no exists where");
                 | 
              |
| 392 | 
                  +is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "relation : no exists where");
                 | 
              |
| 396 | 393 | 
                   | 
              
| 397 | 394 | 
                   eval{$dbi->select(table => 'table1', noexist => 1)};
                 | 
              
| 398 | 
                  -like($@, qr/noexist/, "$test: invalid argument");  | 
              |
| 395 | 
                  +like($@, qr/noexist/, "invalid argument");  | 
              |
| 399 | 396 | 
                   | 
              
| 400 | 397 | 
                   | 
              
| 401 | 398 | 
                  test 'fetch filter';  | 
              
| ... | ... | 
                  @@ -410,16 +407,16 @@ $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              
| 410 | 407 | 
                  $result = $dbi->select(table => 'table1');  | 
              
| 411 | 408 | 
                   $result->filter({key1 => 'three_times'});
                 | 
              
| 412 | 409 | 
                  $row = $result->fetch_hash_first;  | 
              
| 413 | 
                  -is_deeply($row, {key1 => 3, key2 => 4}, "$test: default_fetch_filter and filter");
                 | 
              |
| 410 | 
                  +is_deeply($row, {key1 => 3, key2 => 4}, "default_fetch_filter and filter");
                 | 
              |
| 414 | 411 | 
                   | 
              
| 415 | 412 | 
                  test 'filters';  | 
              
| 416 | 413 | 
                  $dbi = DBIx::Custom->new;  | 
              
| 417 | 414 | 
                   | 
              
| 418 | 415 | 
                   is($dbi->filters->{decode_utf8}->(encode_utf8('あ')),
                 | 
              
| 419 | 
                  - 'あ', "$test : decode_utf8");  | 
              |
| 416 | 
                  + 'あ', "decode_utf8");  | 
              |
| 420 | 417 | 
                   | 
              
| 421 | 418 | 
                   is($dbi->filters->{encode_utf8}->('あ'),
                 | 
              
| 422 | 
                  -   encode_utf8('あ'), "$test : encode_utf8");
                 | 
              |
| 419 | 
                  +   encode_utf8('あ'), "encode_utf8");
                 | 
              |
| 423 | 420 | 
                   | 
              
| 424 | 421 | 
                  test 'transaction';  | 
              
| 425 | 422 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| ... | ... | 
                  @@ -430,7 +427,7 @@ $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
                 | 
              
| 430 | 427 | 
                  $dbi->dbh->commit;  | 
              
| 431 | 428 | 
                  $result = $dbi->select(table => 'table1');  | 
              
| 432 | 429 | 
                   is_deeply(scalar $result->fetch_hash_all, [{key1 => 1, key2 => 2}, {key1 => 2, key2 => 3}],
                 | 
              
| 433 | 
                  - "$test : commit");  | 
              |
| 430 | 
                  + "commit");  | 
              |
| 434 | 431 | 
                   | 
              
| 435 | 432 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| 436 | 433 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| ... | ... | 
                  @@ -439,7 +436,7 @@ $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              
| 439 | 436 | 
                  $dbi->dbh->rollback;  | 
              
| 440 | 437 | 
                   | 
              
| 441 | 438 | 
                  $result = $dbi->select(table => 'table1');  | 
              
| 442 | 
                  -ok(! $result->fetch_first, "$test: rollback");  | 
              |
| 439 | 
                  +ok(! $result->fetch_first, "rollback");  | 
              |
| 443 | 440 | 
                   | 
              
| 444 | 441 | 
                  test 'cache';  | 
              
| 445 | 442 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| ... | ... | 
                  @@ -447,7 +444,7 @@ $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 447 | 444 | 
                   $source = 'select * from table1 where {= key1} and {= key2};';
                 | 
              
| 448 | 445 | 
                  $dbi->create_query($source);  | 
              
| 449 | 446 | 
                   is_deeply($dbi->{_cached}->{$source}, 
                 | 
              
| 450 | 
                  -          {sql => "select * from table1 where key1 = ? and key2 = ?;", columns => ['key1', 'key2']}, "$test : cache");
                 | 
              |
| 447 | 
                  +          {sql => "select * from table1 where key1 = ? and key2 = ?;", columns => ['key1', 'key2']}, "cache");
                 | 
              |
| 451 | 448 | 
                   | 
              
| 452 | 449 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| 453 | 450 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| ... | ... | 
                  @@ -462,32 +459,32 @@ $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 462 | 459 | 
                   {
                 | 
              
| 463 | 460 | 
                  local $Carp::Verbose = 0;  | 
              
| 464 | 461 | 
                       eval{$dbi->execute('select * frm table1')};
                 | 
              
| 465 | 
                  - like($@, qr/\Qselect * frm table1;/, "$test : fail prepare");  | 
              |
| 466 | 
                  - like($@, qr/\.t /, "$test: fail : not verbose");  | 
              |
| 462 | 
                  + like($@, qr/\Qselect * frm table1;/, "fail prepare");  | 
              |
| 463 | 
                  + like($@, qr/\.t /, "fail : not verbose");  | 
              |
| 467 | 464 | 
                  }  | 
              
| 468 | 465 | 
                   {
                 | 
              
| 469 | 466 | 
                  local $Carp::Verbose = 1;  | 
              
| 470 | 467 | 
                       eval{$dbi->execute('select * frm table1')};
                 | 
              
| 471 | 
                  - like($@, qr/Custom.*\.t /s, "$test : fail : verbose");  | 
              |
| 468 | 
                  + like($@, qr/Custom.*\.t /s, "fail : verbose");  | 
              |
| 472 | 469 | 
                  }  | 
              
| 473 | 470 | 
                   | 
              
| 474 | 471 | 
                   eval{$dbi->execute('select * from table1', no_exists => 1)};
                 | 
              
| 475 | 
                  -like($@, qr/\Q"no_exists" is invalid argument/, "$test : invald SQL");  | 
              |
| 472 | 
                  +like($@, qr/\Q"no_exists" is invalid argument/, "invald SQL");  | 
              |
| 476 | 473 | 
                   | 
              
| 477 | 474 | 
                   $query = $dbi->create_query('select * from table1 where {= key1}');
                 | 
              
| 478 | 475 | 
                  $dbi->dbh->disconnect;  | 
              
| 479 | 476 | 
                   eval{$dbi->execute($query, param => {key1 => {a => 1}})};
                 | 
              
| 480 | 
                  -ok($@, "$test: execute fail");  | 
              |
| 477 | 
                  +ok($@, "execute fail");  | 
              |
| 481 | 478 | 
                   | 
              
| 482 | 479 | 
                   {
                 | 
              
| 483 | 480 | 
                  local $Carp::Verbose = 0;  | 
              
| 484 | 481 | 
                       eval{$dbi->create_query('select * from table1 where {0 key1}')};
                 | 
              
| 485 | 
                  - like($@, qr/\Q.t /, "$test : caller spec : not vebose");  | 
              |
| 482 | 
                  + like($@, qr/\Q.t /, "caller spec : not vebose");  | 
              |
| 486 | 483 | 
                  }  | 
              
| 487 | 484 | 
                   {
                 | 
              
| 488 | 485 | 
                  local $Carp::Verbose = 1;  | 
              
| 489 | 486 | 
                       eval{$dbi->create_query('select * from table1 where {0 key1}')};
                 | 
              
| 490 | 
                  - like($@, qr/QueryBuilder.*\.t /s, "$test : caller spec : not vebose");  | 
              |
| 487 | 
                  + like($@, qr/QueryBuilder.*\.t /s, "caller spec : not vebose");  | 
              |
| 491 | 488 | 
                  }  | 
              
| 492 | 489 | 
                   | 
              
| 493 | 490 | 
                   | 
              
| ... | ... | 
                  @@ -507,7 +504,7 @@ $dbi->rollback if $@;  | 
              
| 507 | 504 | 
                   | 
              
| 508 | 505 | 
                  $result = $dbi->select(table => 'table1');  | 
              
| 509 | 506 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 510 | 
                  -is_deeply($rows, [], "$test : rollback");  | 
              |
| 507 | 
                  +is_deeply($rows, [], "rollback");  | 
              |
| 511 | 508 | 
                   | 
              
| 512 | 509 | 
                  $dbi->begin_work;  | 
              
| 513 | 510 | 
                   | 
              
| ... | ... | 
                  @@ -520,11 +517,11 @@ $dbi->commit unless $@;  | 
              
| 520 | 517 | 
                   | 
              
| 521 | 518 | 
                  $result = $dbi->select(table => 'table1');  | 
              
| 522 | 519 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 523 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "$test : commit");
                 | 
              |
| 520 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "commit");
                 | 
              |
| 524 | 521 | 
                   | 
              
| 525 | 522 | 
                   $dbi->dbh->{AutoCommit} = 0;
                 | 
              
| 526 | 523 | 
                   eval{ $dbi->begin_work };
                 | 
              
| 527 | 
                  -ok($@, "$test : exception");  | 
              |
| 524 | 
                  +ok($@, "exception");  | 
              |
| 528 | 525 | 
                   $dbi->dbh->{AutoCommit} = 1;
                 | 
              
| 529 | 526 | 
                   | 
              
| 530 | 527 | 
                   | 
              
| ... | ... | 
                  @@ -543,12 +540,12 @@ $dbi->helper({
                 | 
              
| 543 | 540 | 
                  }  | 
              
| 544 | 541 | 
                  });  | 
              
| 545 | 542 | 
                   | 
              
| 546 | 
                  -is($dbi->one, 1, "$test : first");  | 
              |
| 547 | 
                  -is($dbi->two, 2, "$test : second");  | 
              |
| 548 | 
                  -is($dbi->twice(5), 10 , "$test : second");  | 
              |
| 543 | 
                  +is($dbi->one, 1, "first");  | 
              |
| 544 | 
                  +is($dbi->two, 2, "second");  | 
              |
| 545 | 
                  +is($dbi->twice(5), 10 , "second");  | 
              |
| 549 | 546 | 
                   | 
              
| 550 | 547 | 
                   eval {$dbi->XXXXXX};
                 | 
              
| 551 | 
                  -like($@, qr/\QCan't locate object method "XXXXXX" via "DBIx::Custom"/, "$test : not exists");  | 
              |
| 548 | 
                  +like($@, qr/\QCan't locate object method "XXXXXX" via "DBIx::Custom"/, "not exists");  | 
              |
| 552 | 549 | 
                   | 
              
| 553 | 550 | 
                  test 'out filter';  | 
              
| 554 | 551 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| ... | ... | 
                  @@ -561,10 +558,10 @@ $dbi->apply_filter(  | 
              
| 561 | 558 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              
| 562 | 559 | 
                   $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 563 | 560 | 
                  $row = $result->fetch_hash_first;  | 
              
| 564 | 
                  -is_deeply($row, {key1 => 2, key2 => 6}, "$test : insert");
                 | 
              |
| 561 | 
                  +is_deeply($row, {key1 => 2, key2 => 6}, "insert");
                 | 
              |
| 565 | 562 | 
                  $result = $dbi->select(table => 'table1');  | 
              
| 566 | 563 | 
                  $row = $result->fetch_hash_first;  | 
              
| 567 | 
                  -is_deeply($row, {key1 => 6, key2 => 12}, "$test : insert");
                 | 
              |
| 564 | 
                  +is_deeply($row, {key1 => 6, key2 => 12}, "insert");
                 | 
              |
| 568 | 565 | 
                   | 
              
| 569 | 566 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| 570 | 567 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| ... | ... | 
                  @@ -576,7 +573,7 @@ $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, filter => {key1
                 | 
              
| 576 | 573 | 
                   $dbi->update(table => 'table1', param => {key1 => 2}, where => {key2 => 2});
                 | 
              
| 577 | 574 | 
                   $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 578 | 575 | 
                  $row = $result->fetch_hash_first;  | 
              
| 579 | 
                  -is_deeply($row, {key1 => 4, key2 => 2}, "$test : update");
                 | 
              |
| 576 | 
                  +is_deeply($row, {key1 => 4, key2 => 2}, "update");
                 | 
              |
| 580 | 577 | 
                   | 
              
| 581 | 578 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| 582 | 579 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| ... | ... | 
                  @@ -588,7 +585,7 @@ $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1
                 | 
              
| 588 | 585 | 
                   $dbi->delete(table => 'table1', where => {key1 => 1});
                 | 
              
| 589 | 586 | 
                   $result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              
| 590 | 587 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 591 | 
                  -is_deeply($rows, [], "$test : delete");  | 
              |
| 588 | 
                  +is_deeply($rows, [], "delete");  | 
              |
| 592 | 589 | 
                   | 
              
| 593 | 590 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| 594 | 591 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| ... | ... | 
                  @@ -600,7 +597,7 @@ $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1
                 | 
              
| 600 | 597 | 
                   $result = $dbi->select(table => 'table1', where => {key1 => 1});
                 | 
              
| 601 | 598 | 
                   $result->filter({'key2' => 'twice'});
                 | 
              
| 602 | 599 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 603 | 
                  -is_deeply($rows, [{key1 => 4, key2 => 4}], "$test : select");
                 | 
              |
| 600 | 
                  +is_deeply($rows, [{key1 => 4, key2 => 4}], "select");
                 | 
              |
| 604 | 601 | 
                   | 
              
| 605 | 602 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| 606 | 603 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| ... | ... | 
                  @@ -613,7 +610,7 @@ $result = $dbi->execute("select * from table1 where {= key1} and {= key2};",
                 | 
              
| 613 | 610 | 
                                           param => {key1 => 1, key2 => 2},
                 | 
              
| 614 | 611 | 
                  table => ['table1']);  | 
              
| 615 | 612 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 616 | 
                  -is_deeply($rows, [{key1 => 4, key2 => 2}], "$test : execute");
                 | 
              |
| 613 | 
                  +is_deeply($rows, [{key1 => 4, key2 => 2}], "execute");
                 | 
              |
| 617 | 614 | 
                   | 
              
| 618 | 615 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| 619 | 616 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| ... | ... | 
                  @@ -635,7 +632,7 @@ $result = $dbi->select(  | 
              
| 635 | 632 | 
                   | 
              
| 636 | 633 | 
                   $result->filter({'key2' => 'twice'});
                 | 
              
| 637 | 634 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 638 | 
                  -is_deeply($rows, [{key2 => 4, key3 => 18}], "$test : select : join");
                 | 
              |
| 635 | 
                  +is_deeply($rows, [{key2 => 4, key3 => 18}], "select : join");
                 | 
              |
| 639 | 636 | 
                   | 
              
| 640 | 637 | 
                  $result = $dbi->select(  | 
              
| 641 | 638 | 
                  table => ['table1', 'table2'],  | 
              
| ... | ... | 
                  @@ -644,7 +641,7 @@ $result = $dbi->select(  | 
              
| 644 | 641 | 
                   | 
              
| 645 | 642 | 
                   $result->filter({'key2' => 'twice'});
                 | 
              
| 646 | 643 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 647 | 
                  -is_deeply($rows, [{key2 => 4, key3 => 18}], "$test : select : join : omit");
                 | 
              |
| 644 | 
                  +is_deeply($rows, [{key2 => 4, key3 => 18}], "select : join : omit");
                 | 
              |
| 648 | 645 | 
                   | 
              
| 649 | 646 | 
                  test 'each_column';  | 
              
| 650 | 647 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| ... | ... | 
                  @@ -668,7 +665,7 @@ is_deeply($infos,  | 
              
| 668 | 665 | 
                  ['table2', 'key1', 'key1'],  | 
              
| 669 | 666 | 
                  ['table2', 'key3', 'key3']  | 
              
| 670 | 667 | 
                  ]  | 
              
| 671 | 
                  - , $test  | 
              |
| 668 | 
                  +  | 
              |
| 672 | 669 | 
                  );  | 
              
| 673 | 670 | 
                   | 
              
| 674 | 671 | 
                  test 'table';  | 
              
| ... | ... | 
                  @@ -679,25 +676,25 @@ $table->insert(param => {key1 => 1, key2 => 2});
                 | 
              
| 679 | 676 | 
                   $table->insert(param => {key1 => 3, key2 => 4});
                 | 
              
| 680 | 677 | 
                  $rows = $table->select->fetch_hash_all;  | 
              
| 681 | 678 | 
                   is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}],
                 | 
              
| 682 | 
                  - "$test: select");  | 
              |
| 679 | 
                  + "select");  | 
              |
| 683 | 680 | 
                   $rows = $table->select(where => {key2 => 2}, append => 'order by key1',
                 | 
              
| 684 | 681 | 
                  column => ['key1', 'key2'])->fetch_hash_all;  | 
              
| 685 | 682 | 
                   is_deeply($rows, [{key1 => 1, key2 => 2}],
                 | 
              
| 686 | 
                  - "$test: insert insert select");  | 
              |
| 683 | 
                  + "insert insert select");  | 
              |
| 687 | 684 | 
                   $table->update(param => {key1 => 3}, where => {key2 => 2});
                 | 
              
| 688 | 685 | 
                   $table->update(param => {key1 => 5}, where => {key2 => 4});
                 | 
              
| 689 | 686 | 
                   $rows = $table->select(where => {key2 => 2})->fetch_hash_all;
                 | 
              
| 690 | 687 | 
                   is_deeply($rows, [{key1 => 3, key2 => 2}],
                 | 
              
| 691 | 
                  - "$test: update");  | 
              |
| 688 | 
                  + "update");  | 
              |
| 692 | 689 | 
                   $table->delete(where => {key2 => 2});
                 | 
              
| 693 | 690 | 
                  $rows = $table->select->fetch_hash_all;  | 
              
| 694 | 
                  -is_deeply($rows, [{key1 => 5, key2 => 4}], "$test: delete");
                 | 
              |
| 691 | 
                  +is_deeply($rows, [{key1 => 5, key2 => 4}], "delete");
                 | 
              |
| 695 | 692 | 
                   $table->update_all(param => {key1 => 3});
                 | 
              
| 696 | 693 | 
                  $rows = $table->select->fetch_hash_all;  | 
              
| 697 | 
                  -is_deeply($rows, [{key1 => 3, key2 => 4}], "$test: update_all");
                 | 
              |
| 694 | 
                  +is_deeply($rows, [{key1 => 3, key2 => 4}], "update_all");
                 | 
              |
| 698 | 695 | 
                  $table->delete_all;  | 
              
| 699 | 696 | 
                  $rows = $table->select->fetch_hash_all;  | 
              
| 700 | 
                  -is_deeply($rows, [], "$test: delete_all");  | 
              |
| 697 | 
                  +is_deeply($rows, [], "delete_all");  | 
              |
| 701 | 698 | 
                   | 
              
| 702 | 699 | 
                   $dbi->dbh->do($CREATE_TABLE->{2});
                 | 
              
| 703 | 700 | 
                   $dbi->table('table2', ppp => sub {
                 | 
              
| ... | ... | 
                  @@ -705,14 +702,14 @@ $dbi->table('table2', ppp => sub {
                 | 
              
| 705 | 702 | 
                   | 
              
| 706 | 703 | 
                  return $self->name;  | 
              
| 707 | 704 | 
                  });  | 
              
| 708 | 
                  -is($dbi->table('table2')->ppp, 'table2', "$test : helper");
                 | 
              |
| 705 | 
                  +is($dbi->table('table2')->ppp, 'table2', "helper");
                 | 
              |
| 709 | 706 | 
                   | 
              
| 710 | 707 | 
                   $dbi->table('table2', {qqq => sub {
                 | 
              
| 711 | 708 | 
                  my $self = shift;  | 
              
| 712 | 709 | 
                   | 
              
| 713 | 710 | 
                  return $self->name;  | 
              
| 714 | 711 | 
                  }});  | 
              
| 715 | 
                  -is($dbi->table('table2')->qqq, 'table2', "$test : helper");
                 | 
              |
| 712 | 
                  +is($dbi->table('table2')->qqq, 'table2', "helper");
                 | 
              |
| 716 | 713 | 
                   | 
              
| 717 | 714 | 
                   | 
              
| 718 | 715 | 
                  test 'limit';  | 
              
| ... | ... | 
                  @@ -737,19 +734,19 @@ $rows = $dbi->select(  | 
              
| 737 | 734 | 
                     where => {key1 => 1},
                 | 
              
| 738 | 735 | 
                     append => "order by key2 {limit 1 0}"
                 | 
              
| 739 | 736 | 
                  )->fetch_hash_all;  | 
              
| 740 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2}], $test);
                 | 
              |
| 737 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2}]);
                 | 
              |
| 741 | 738 | 
                  $rows = $dbi->select(  | 
              
| 742 | 739 | 
                  table => 'table1',  | 
              
| 743 | 740 | 
                     where => {key1 => 1},
                 | 
              
| 744 | 741 | 
                     append => "order by key2 {limit 2 1}"
                 | 
              
| 745 | 742 | 
                  )->fetch_hash_all;  | 
              
| 746 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 4},{key1 => 1, key2 => 6}], $test);
                 | 
              |
| 743 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 4},{key1 => 1, key2 => 6}]);
                 | 
              |
| 747 | 744 | 
                  $rows = $dbi->select(  | 
              
| 748 | 745 | 
                  table => 'table1',  | 
              
| 749 | 746 | 
                     where => {key1 => 1},
                 | 
              
| 750 | 747 | 
                     append => "order by key2 {limit 1}"
                 | 
              
| 751 | 748 | 
                  )->fetch_hash_all;  | 
              
| 752 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2}], $test);
                 | 
              |
| 749 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2}]);
                 | 
              |
| 753 | 750 | 
                   | 
              
| 754 | 751 | 
                  test 'connect super';  | 
              
| 755 | 752 | 
                   {
                 | 
              
| ... | ... | 
                  @@ -772,12 +769,12 @@ test 'connect super';  | 
              
| 772 | 769 | 
                   $dbi = MyDBI->connect($NEW_ARGS->{0});
                 | 
              
| 773 | 770 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 774 | 771 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              
| 775 | 
                  -is($dbi->select(table => 'table1')->fetch_hash_first->{key1}, 1, $test);
                 | 
              |
| 772 | 
                  +is($dbi->select(table => 'table1')->fetch_hash_first->{key1}, 1);
                 | 
              |
| 776 | 773 | 
                   | 
              
| 777 | 774 | 
                   $dbi = MyDBI->new($NEW_ARGS->{0});
                 | 
              
| 778 | 775 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 779 | 776 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              
| 780 | 
                  -is($dbi->select(table => 'table1')->fetch_hash_first->{key1}, 1, $test);
                 | 
              |
| 777 | 
                  +is($dbi->select(table => 'table1')->fetch_hash_first->{key1}, 1);
                 | 
              |
| 781 | 778 | 
                   | 
              
| 782 | 779 | 
                   | 
              
| 783 | 780 | 
                  test 'end_filter';  | 
              
| ... | ... | 
                  @@ -7,9 +7,7 @@ use DBIx::Custom::QueryBuilder;  | 
              
| 7 | 7 | 
                   | 
              
| 8 | 8 | 
                  # Function for test name  | 
              
| 9 | 9 | 
                  my $test;  | 
              
| 10 | 
                  -sub test {
                 | 
              |
| 11 | 
                  - $test = shift;  | 
              |
| 12 | 
                  -}  | 
              |
| 10 | 
                  +sub test { "# $_[0]\n" }
                 | 
              |
| 13 | 11 | 
                   | 
              
| 14 | 12 | 
                  # Variables for test  | 
              
| 15 | 13 | 
                  my $dbi;  | 
              
| ... | ... | 
                  @@ -32,7 +30,7 @@ $dbi = DBIx::Custom->new(  | 
              
| 32 | 30 | 
                   is_deeply($dbi,{user => 'a', password => 'b', data_source => 'c', 
                 | 
              
| 33 | 31 | 
                                   filters => {f => 3}, default_bind_filter => 'f',
                 | 
              
| 34 | 32 | 
                  default_fetch_filter => 'g', result_class => 'g',  | 
              
| 35 | 
                  - query_builder => $query_builder}, $test);  | 
              |
| 33 | 
                  + query_builder => $query_builder});  | 
              |
| 36 | 34 | 
                  isa_ok($dbi, 'DBIx::Custom');  | 
              
| 37 | 35 | 
                   | 
              
| 38 | 36 | 
                   | 
              
| ... | ... | 
                  @@ -47,7 +45,7 @@ $dbi = DBIx::Custom::T1->new(  | 
              
| 47 | 45 | 
                  fo => 30,  | 
              
| 48 | 46 | 
                  },  | 
              
| 49 | 47 | 
                  );  | 
              
| 50 | 
                  -is_deeply(scalar $dbi->filters, {fo => 30}, "$test : filters");
                 | 
              |
| 48 | 
                  +is_deeply(scalar $dbi->filters, {fo => 30}, "filters");
                 | 
              |
| 51 | 49 | 
                   | 
              
| 52 | 50 | 
                  test 'Sub sub class constructor default';  | 
              
| 53 | 51 | 
                   {
                 | 
              
| ... | ... | 
                  @@ -74,16 +72,16 @@ $dbi = DBIx::Custom::T1_3->new(  | 
              
| 74 | 72 | 
                  f => 3,  | 
              
| 75 | 73 | 
                  },  | 
              
| 76 | 74 | 
                  );  | 
              
| 77 | 
                  -is_deeply($dbi->filters, {f => 3}, "$test : filters");
                 | 
              |
| 75 | 
                  +is_deeply($dbi->filters, {f => 3}, "filters");
                 | 
              |
| 78 | 76 | 
                  isa_ok($dbi, 'DBIx::Custom');  | 
              
| 79 | 77 | 
                   | 
              
| 80 | 78 | 
                   | 
              
| 81 | 79 | 
                  test 'register_filters';  | 
              
| 82 | 80 | 
                  $dbi = DBIx::Custom->new;  | 
              
| 83 | 81 | 
                   $dbi->register_filter(a => sub {1});
                 | 
              
| 84 | 
                  -is($dbi->filters->{a}->(), 1, $test);
                 | 
              |
| 82 | 
                  +is($dbi->filters->{a}->(), 1);
                 | 
              |
| 85 | 83 | 
                   $dbi->register_filter({b => sub {2}});
                 | 
              
| 86 | 
                  -is($dbi->filters->{b}->(), 2, $test);
                 | 
              |
| 84 | 
                  +is($dbi->filters->{b}->(), 2);
                 | 
              |
| 87 | 85 | 
                   | 
              
| 88 | 86 | 
                   | 
              
| 89 | 87 | 
                  test 'expand';  | 
              
| ... | ... | 
                  @@ -102,4 +100,4 @@ test 'expand';  | 
              
| 102 | 100 | 
                   | 
              
| 103 | 101 | 
                  test 'invalid attribute name';  | 
              
| 104 | 102 | 
                   eval {$dbi = DBIx::Custom->new(a => 1) };
                 | 
              
| 105 | 
                  -like ($@, qr/"a" is invalid attribute name/, $test);  | 
              |
| 103 | 
                  +like ($@, qr/"a" is invalid attribute name/);  | 
              
| ... | ... | 
                  @@ -10,11 +10,7 @@ plan skip_all => 'private MySQL test' unless $USER;  | 
              
| 10 | 10 | 
                  plan 'no_plan';  | 
              
| 11 | 11 | 
                   | 
              
| 12 | 12 | 
                  # Function for test name  | 
              
| 13 | 
                  -my $test;  | 
              |
| 14 | 
                  -sub test {
                 | 
              |
| 15 | 
                  - $test = shift;  | 
              |
| 16 | 
                  -}  | 
              |
| 17 | 
                  -  | 
              |
| 13 | 
                  +sub test { print "# $_[0]\n" }
                 | 
              |
| 18 | 14 | 
                   | 
              
| 19 | 15 | 
                  # Functions for tests  | 
              
| 20 | 16 | 
                   sub connect_info {
                 | 
              
| ... | ... | 
                  @@ -47,15 +43,15 @@ test 'connect';  | 
              
| 47 | 43 | 
                  $dbi = DBIx::Custom::MySQL->new(user => $USER, password => $PASSWORD,  | 
              
| 48 | 44 | 
                  database => $DATABASE, host => 'localhost', port => '10000');  | 
              
| 49 | 45 | 
                  $dbi->connect;  | 
              
| 50 | 
                  -like($dbi->data_source, qr/dbi:mysql:database=.*;host=localhost;port=10000;/, "$test : created data source");  | 
              |
| 51 | 
                  -is(ref $dbi->dbh, 'DBI::db', $test);  | 
              |
| 46 | 
                  +like($dbi->data_source, qr/dbi:mysql:database=.*;host=localhost;port=10000;/, "created data source");  | 
              |
| 47 | 
                  +is(ref $dbi->dbh, 'DBI::db');  | 
              |
| 52 | 48 | 
                   | 
              
| 53 | 49 | 
                  test 'attributes';  | 
              
| 54 | 50 | 
                  $dbi = DBIx::Custom::MySQL->new;  | 
              
| 55 | 51 | 
                   $dbi->host('a');
                 | 
              
| 56 | 
                  -is($dbi->host, 'a', "$test: host");  | 
              |
| 52 | 
                  +is($dbi->host, 'a', "host");  | 
              |
| 57 | 53 | 
                   $dbi->port('b');
                 | 
              
| 58 | 
                  -is($dbi->port, 'b', "$test: port");  | 
              |
| 54 | 
                  +is($dbi->port, 'b', "port");  | 
              |
| 59 | 55 | 
                   | 
              
| 60 | 56 | 
                  test 'limit';  | 
              
| 61 | 57 | 
                  $dbi = DBIx::Custom->connect(  | 
              
| ... | ... | 
                  @@ -83,17 +79,17 @@ $rows = $dbi->select(  | 
              
| 83 | 79 | 
                     where => {key1 => 1},
                 | 
              
| 84 | 80 | 
                     append => "order by key2 {limit 1 0}"
                 | 
              
| 85 | 81 | 
                  )->fetch_hash_all;  | 
              
| 86 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2}], $test);
                 | 
              |
| 82 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2}]);
                 | 
              |
| 87 | 83 | 
                  $rows = $dbi->select(  | 
              
| 88 | 84 | 
                  table => 'table1',  | 
              
| 89 | 85 | 
                     where => {key1 => 1},
                 | 
              
| 90 | 86 | 
                     append => "order by key2 {limit 2 1}"
                 | 
              
| 91 | 87 | 
                  )->fetch_hash_all;  | 
              
| 92 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 4},{key1 => 1, key2 => 6}], $test);
                 | 
              |
| 88 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 4},{key1 => 1, key2 => 6}]);
                 | 
              |
| 93 | 89 | 
                  $rows = $dbi->select(  | 
              
| 94 | 90 | 
                  table => 'table1',  | 
              
| 95 | 91 | 
                     where => {key1 => 1},
                 | 
              
| 96 | 92 | 
                     append => "order by key2 {limit 1}"
                 | 
              
| 97 | 93 | 
                  )->fetch_hash_all;  | 
              
| 98 | 
                  -is_deeply($rows, [{key1 => 1, key2 => 2}], $test);
                 | 
              |
| 94 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 2}]);
                 | 
              |
| 99 | 95 | 
                  $dbi->delete_all(table => 'table1');  | 
              
| ... | ... | 
                  @@ -5,10 +5,7 @@ use warnings;  | 
              
| 5 | 5 | 
                  use DBIx::Custom::Query;  | 
              
| 6 | 6 | 
                   | 
              
| 7 | 7 | 
                  # Function for test name  | 
              
| 8 | 
                  -my $test;  | 
              |
| 9 | 
                  -sub test{
                 | 
              |
| 10 | 
                  - $test = shift;  | 
              |
| 11 | 
                  -}  | 
              |
| 8 | 
                  +sub test{ "# $_[0]\n" }
                 | 
              |
| 12 | 9 | 
                   | 
              
| 13 | 10 | 
                  # Variables for test  | 
              
| 14 | 11 | 
                  my $query;  | 
              
| ... | ... | 
                  @@ -22,8 +19,8 @@ $query = DBIx::Custom::Query->new(  | 
              
| 22 | 19 | 
                  fetch_filter => 'f',  | 
              
| 23 | 20 | 
                  );  | 
              
| 24 | 21 | 
                   | 
              
| 25 | 
                  -is($query->sql, 'a', "$test : sql");  | 
              |
| 26 | 
                  -is($query->columns, 'b', "$test : columns ");  | 
              |
| 27 | 
                  -is($query->filter, 'c', "$test : filter");  | 
              |
| 28 | 
                  -is($query->sth, 'e', "$test : sth");  | 
              |
| 22 | 
                  +is($query->sql, 'a', "sql");  | 
              |
| 23 | 
                  +is($query->columns, 'b', "columns ");  | 
              |
| 24 | 
                  +is($query->filter, 'c', "filter");  | 
              |
| 25 | 
                  +is($query->sth, 'e', "sth");  | 
              |
| 29 | 26 | 
                   | 
              
| ... | ... | 
                  @@ -6,10 +6,7 @@ use Test::More 'no_plan';  | 
              
| 6 | 6 | 
                  use DBIx::Custom::QueryBuilder;  | 
              
| 7 | 7 | 
                   | 
              
| 8 | 8 | 
                  # Function for test name  | 
              
| 9 | 
                  -my $test;  | 
              |
| 10 | 
                  -sub test{
                 | 
              |
| 11 | 
                  - $test = shift;  | 
              |
| 12 | 
                  -}  | 
              |
| 9 | 
                  +sub test{ "# $_[0]\n" }
                 | 
              |
| 13 | 10 | 
                   | 
              
| 14 | 11 | 
                  # Variable for test  | 
              
| 15 | 12 | 
                  my $datas;  | 
              
| ... | ... | 
                  @@ -59,8 +56,8 @@ for (my $i = 0; $i < @$datas; $i++) {
                 | 
              
| 59 | 56 | 
                  my $data = $datas->[$i];  | 
              
| 60 | 57 | 
                  my $builder = DBIx::Custom::QueryBuilder->new;  | 
              
| 61 | 58 | 
                       my $query = $builder->build_query($data->{source});
                 | 
              
| 62 | 
                  -    is($query->{sql}, $data->{sql_expected}, "$test : $data->{name} : sql");
                 | 
              |
| 63 | 
                  -    is_deeply($query->{columns}, $data->{columns_expected}, "$test : $data->{name} : columns");
                 | 
              |
| 59 | 
                  +    is($query->{sql}, $data->{sql_expected}, "$data->{name} : sql");
                 | 
              |
| 60 | 
                  +    is_deeply($query->{columns}, $data->{columns_expected}, "$data->{name} : columns");
                 | 
              |
| 64 | 61 | 
                  }  | 
              
| 65 | 62 | 
                   | 
              
| 66 | 63 | 
                   | 
              
| ... | ... | 
                  @@ -78,8 +75,8 @@ $ret_val = $builder->register_tag_processor(  | 
              
| 78 | 75 | 
                  );  | 
              
| 79 | 76 | 
                   | 
              
| 80 | 77 | 
                   $query = $builder->build_query("{p a b}");
                 | 
              
| 81 | 
                  -is($query->{sql}, "? a b;", "$test : register_tag_processor sql");
                 | 
              |
| 82 | 
                  -is_deeply($query->{columns}, [2], "$test : register_tag_processor columns");
                 | 
              |
| 78 | 
                  +is($query->{sql}, "? a b;", "register_tag_processor sql");
                 | 
              |
| 79 | 
                  +is_deeply($query->{columns}, [2], "register_tag_processor columns");
                 | 
              |
| 83 | 80 | 
                  isa_ok($ret_val, 'DBIx::Custom::QueryBuilder');  | 
              
| 84 | 81 | 
                   | 
              
| 85 | 82 | 
                   | 
              
| ... | ... | 
                  @@ -87,31 +84,31 @@ test "Tag processor error case";  | 
              
| 87 | 84 | 
                  $builder = DBIx::Custom::QueryBuilder->new;  | 
              
| 88 | 85 | 
                   | 
              
| 89 | 86 | 
                   eval{$builder->build_query('{? }')};
                 | 
              
| 90 | 
                  -like($@, qr/\QColumn name must be specified in tag "{? }"/, "$test : ? not arguments");
                 | 
              |
| 87 | 
                  +like($@, qr/\QColumn name must be specified in tag "{? }"/, "? not arguments");
                 | 
              |
| 91 | 88 | 
                   | 
              
| 92 | 89 | 
                   eval{$builder->build_query("{a }")};
                 | 
              
| 93 | 
                  -like($@, qr/\QTag "a" in "{a }" is not registered/, "$test : tag_processor not exist");
                 | 
              |
| 90 | 
                  +like($@, qr/\QTag "a" in "{a }" is not registered/, "tag_processor not exist");
                 | 
              |
| 94 | 91 | 
                   | 
              
| 95 | 92 | 
                   $builder->register_tag_processor({
                 | 
              
| 96 | 93 | 
                  q => 'string'  | 
              
| 97 | 94 | 
                  });  | 
              
| 98 | 95 | 
                   | 
              
| 99 | 96 | 
                   eval{$builder->build_query("{q}", {})};
                 | 
              
| 100 | 
                  -like($@, qr/Tag processor "q" must be sub reference/, "$test : tag_processor not code ref");  | 
              |
| 97 | 
                  +like($@, qr/Tag processor "q" must be sub reference/, "tag_processor not code ref");  | 
              |
| 101 | 98 | 
                   | 
              
| 102 | 99 | 
                   $builder->register_tag_processor({
                 | 
              
| 103 | 100 | 
                      r => sub {} 
                 | 
              
| 104 | 101 | 
                  });  | 
              
| 105 | 102 | 
                   | 
              
| 106 | 103 | 
                   eval{$builder->build_query("{r}")};
                 | 
              
| 107 | 
                  -like($@, qr/\QTag processor "r" must return [STRING, ARRAY_REFERENCE]/, "$test : tag processor return noting");  | 
              |
| 104 | 
                  +like($@, qr/\QTag processor "r" must return [STRING, ARRAY_REFERENCE]/, "tag processor return noting");  | 
              |
| 108 | 105 | 
                   | 
              
| 109 | 106 | 
                   $builder->register_tag_processor({
                 | 
              
| 110 | 107 | 
                      s => sub { return ["a", ""]} 
                 | 
              
| 111 | 108 | 
                  });  | 
              
| 112 | 109 | 
                   | 
              
| 113 | 110 | 
                   eval{$builder->build_query("{s}")};
                 | 
              
| 114 | 
                  -like($@, qr/\QTag processor "s" must return [STRING, ARRAY_REFERENCE]/, "$test : tag processor return not array columns");  | 
              |
| 111 | 
                  +like($@, qr/\QTag processor "s" must return [STRING, ARRAY_REFERENCE]/, "tag processor return not array columns");  | 
              |
| 115 | 112 | 
                   | 
              
| 116 | 113 | 
                  $builder->register_tag_processor(  | 
              
| 117 | 114 | 
                       t => sub {return ["a", []]}
                 | 
              
| ... | ... | 
                  @@ -126,47 +123,47 @@ $builder->register_tag_processor(  | 
              
| 126 | 123 | 
                  }  | 
              
| 127 | 124 | 
                  );  | 
              
| 128 | 125 | 
                   eval{$builder->build_query("{a}")};
                 | 
              
| 129 | 
                  -like($@, qr/\QPlaceholder count in "? ? ?" must be same as column count 1/, "$test : placeholder count is invalid");  | 
              |
| 126 | 
                  +like($@, qr/\QPlaceholder count in "? ? ?" must be same as column count 1/, "placeholder count is invalid");  | 
              |
| 130 | 127 | 
                   | 
              
| 131 | 128 | 
                   | 
              
| 132 | 129 | 
                  test 'Default tag processor Error case';  | 
              
| 133 | 130 | 
                   eval{$builder->build_query("{= }")};
                 | 
              
| 134 | 
                  -like($@, qr/Column name must be specified in tag "{= }"/, "$test : basic '=' : key not exist");
                 | 
              |
| 131 | 
                  +like($@, qr/Column name must be specified in tag "{= }"/, "basic '=' : key not exist");
                 | 
              |
| 135 | 132 | 
                   | 
              
| 136 | 133 | 
                   eval{$builder->build_query("{in }")};
                 | 
              
| 137 | 
                  -like($@, qr/Column name and count of values must be specified in tag "{in }"/, "$test : in : key not exist");
                 | 
              |
| 134 | 
                  +like($@, qr/Column name and count of values must be specified in tag "{in }"/, "in : key not exist");
                 | 
              |
| 138 | 135 | 
                   | 
              
| 139 | 136 | 
                   eval{$builder->build_query("{in a}")};
                 | 
              
| 140 | 137 | 
                   like($@, qr/\QColumn name and count of values must be specified in tag "{in }"/,
                 | 
              
| 141 | 
                  - "$test : in : key not exist");  | 
              |
| 138 | 
                  + "in : key not exist");  | 
              |
| 142 | 139 | 
                   | 
              
| 143 | 140 | 
                   eval{$builder->build_query("{in a r}")};
                 | 
              
| 144 | 141 | 
                   like($@, qr/\QColumn name and count of values must be specified in tag "{in }"/,
                 | 
              
| 145 | 
                  - "$test : in : key not exist");  | 
              |
| 142 | 
                  + "in : key not exist");  | 
              |
| 146 | 143 | 
                   | 
              
| 147 | 144 | 
                  test 'variouse source';  | 
              
| 148 | 145 | 
                   $source = "a {= b} c \\{ \\} {= \\{} {= \\}} d;";
                 | 
              
| 149 | 146 | 
                  $query = $builder->build_query($source);  | 
              
| 150 | 
                  -is($query->sql, 'a b = ? c { } { = ? } = ? d;', "$test : basic : 1");
                 | 
              |
| 147 | 
                  +is($query->sql, 'a b = ? c { } { = ? } = ? d;', "basic : 1");
                 | 
              |
| 151 | 148 | 
                   | 
              
| 152 | 149 | 
                  $source = "abc;";  | 
              
| 153 | 150 | 
                  $query = $builder->build_query($source);  | 
              
| 154 | 
                  -is($query->sql, 'abc;', "$test : basic : 2");  | 
              |
| 151 | 
                  +is($query->sql, 'abc;', "basic : 2");  | 
              |
| 155 | 152 | 
                   | 
              
| 156 | 153 | 
                   $source = "{= a}";
                 | 
              
| 157 | 154 | 
                  $query = $builder->build_query($source);  | 
              
| 158 | 
                  -is($query->sql, 'a = ?;', "$test : only tag");  | 
              |
| 155 | 
                  +is($query->sql, 'a = ?;', "only tag");  | 
              |
| 159 | 156 | 
                   | 
              
| 160 | 157 | 
                  $source = "000;";  | 
              
| 161 | 158 | 
                  $query = $builder->build_query($source);  | 
              
| 162 | 
                  -is($query->sql, '000;', "$test : contain 0 value");  | 
              |
| 159 | 
                  +is($query->sql, '000;', "contain 0 value");  | 
              |
| 163 | 160 | 
                   | 
              
| 164 | 161 | 
                   $source = "a {= b} }";
                 | 
              
| 165 | 162 | 
                   eval{$builder->build_query($source)};
                 | 
              
| 166 | 
                  -like($@, qr/unexpected "}"/, "$test : error : 1");  | 
              |
| 163 | 
                  +like($@, qr/unexpected "}"/, "error : 1");  | 
              |
| 167 | 164 | 
                   | 
              
| 168 | 165 | 
                   $source = "a {= {}";
                 | 
              
| 169 | 166 | 
                   eval{$builder->build_query($source)};
                 | 
              
| 170 | 
                  -like($@, qr/unexpected "{"/, "$test : error : 2");
                 | 
              |
| 167 | 
                  +like($@, qr/unexpected "{"/, "error : 2");
                 | 
              |
| 171 | 168 | 
                   | 
              
| 172 | 169 | 
                   | 
              
| ... | ... | 
                  @@ -14,10 +14,7 @@ BEGIN {
                 | 
              
| 14 | 14 | 
                  }  | 
              
| 15 | 15 | 
                   | 
              
| 16 | 16 | 
                  # Function for test name  | 
              
| 17 | 
                  -my $test;  | 
              |
| 18 | 
                  -sub test {
                 | 
              |
| 19 | 
                  - $test = shift;  | 
              |
| 20 | 
                  -}  | 
              |
| 17 | 
                  +sub test { "# $_[0]\n" }
                 | 
              |
| 21 | 18 | 
                   | 
              
| 22 | 19 | 
                  # Constant varialbes for test  | 
              
| 23 | 20 | 
                   my $CREATE_TABLE = {
                 | 
              
| ... | ... | 
                  @@ -37,25 +34,25 @@ my $id;  | 
              
| 37 | 34 | 
                  test 'connect_memory';  | 
              
| 38 | 35 | 
                  $dbi = DBIx::Custom::SQLite->connect_memory;  | 
              
| 39 | 36 | 
                   $ret_val = $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 40 | 
                  -ok(defined $ret_val, $test);  | 
              |
| 37 | 
                  +ok(defined $ret_val);  | 
              |
| 41 | 38 | 
                   $dbi->insert(table => 'table1', param => {key1 => 'a', key2 => 2});
                 | 
              
| 42 | 39 | 
                   $rows = $dbi->select(table => 'table1', where => {key1 => 'a'})->fetch_hash_all;
                 | 
              
| 43 | 
                  -is_deeply($rows, [{key1 => 'a', key2 => 2}], "$test : select rows");
                 | 
              |
| 40 | 
                  +is_deeply($rows, [{key1 => 'a', key2 => 2}], "select rows");
                 | 
              |
| 44 | 41 | 
                   | 
              
| 45 | 42 | 
                  test 'connect';  | 
              
| 46 | 43 | 
                  $db_file = 't/test.db';  | 
              
| 47 | 44 | 
                  unlink $db_file if -f $db_file;  | 
              
| 48 | 45 | 
                  $dbi = DBIx::Custom::SQLite->new(database => $db_file);  | 
              
| 49 | 46 | 
                  $dbi->connect;  | 
              
| 50 | 
                  -ok(-f $db_file, "$test : database file");  | 
              |
| 47 | 
                  +ok(-f $db_file, "database file");  | 
              |
| 51 | 48 | 
                   $ret_val = $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 52 | 
                  -ok(defined $ret_val, "$test : database");  | 
              |
| 49 | 
                  +ok(defined $ret_val, "database");  | 
              |
| 53 | 50 | 
                  $dbi->dbh->disconnect;  | 
              
| 54 | 51 | 
                   | 
              
| 55 | 52 | 
                  unlink $db_file if -f $db_file;  | 
              
| 56 | 53 | 
                  $dbi = DBIx::Custom::SQLite->connect(database => $db_file);  | 
              
| 57 | 
                  -ok($dbi, "$test : called from class name");  | 
              |
| 54 | 
                  +ok($dbi, "called from class name");  | 
              |
| 58 | 55 | 
                   | 
              
| 59 | 56 | 
                  unlink $db_file if -f $db_file;  | 
              
| 60 | 57 | 
                  $dbi = DBIx::Custom::SQLite->connect(data_source => "dbi:SQLite:dbname=$db_file");  | 
              
| 61 | 
                  -ok($dbi, "$test : specified data source");  | 
              |
| 58 | 
                  +ok($dbi, "specified data source");  | 
              
| ... | ... | 
                  @@ -8,8 +8,7 @@ plan 'no_plan';  | 
              
| 8 | 8 | 
                  use DBIx::Custom;  | 
              
| 9 | 9 | 
                   | 
              
| 10 | 10 | 
                  # Function for test name  | 
              
| 11 | 
                  -my $test;  | 
              |
| 12 | 
                  -sub test {$test = shift }
                 | 
              |
| 11 | 
                  +sub test { "# $_[0]\n" }
                 | 
              |
| 13 | 12 | 
                   | 
              
| 14 | 13 | 
                  # Constant varialbes for test  | 
              
| 15 | 14 | 
                   my $CREATE_TABLE = {
                 | 
              
| ... | ... | 
                  @@ -36,7 +35,7 @@ $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 36 | 35 | 
                  }  | 
              
| 37 | 36 | 
                  $result = $dbi->select(table => 'table1');  | 
              
| 38 | 37 | 
                   is_deeply(scalar $result->fetch_hash_all, [{key1 => 1, key2 => 2}, {key1 => 2, key2 => 3}],
                 | 
              
| 39 | 
                  - "$test : commit");  | 
              |
| 38 | 
                  + "commit");  | 
              |
| 40 | 39 | 
                   | 
              
| 41 | 40 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| 42 | 41 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| ... | ... | 
                  @@ -49,5 +48,5 @@ $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 49 | 48 | 
                  }  | 
              
| 50 | 49 | 
                  }  | 
              
| 51 | 50 | 
                  $result = $dbi->select(table => 'table1');  | 
              
| 52 | 
                  -ok(! $result->fetch_first, "$test: rollback");  | 
              |
| 51 | 
                  +ok(! $result->fetch_first, "rollback");  | 
              |
| 53 | 52 | 
                   | 
              
| ... | ... | 
                  @@ -1,18 +0,0 @@  | 
              
| 1 | 
                  -use strict;  | 
              |
| 2 | 
                  -use warnings;  | 
              |
| 3 | 
                  -use Test::More;  | 
              |
| 4 | 
                  -  | 
              |
| 5 | 
                  -# Ensure a recent version of Test::Pod::Coverage  | 
              |
| 6 | 
                  -my $min_tpc = 1.08;  | 
              |
| 7 | 
                  -eval "use Test::Pod::Coverage $min_tpc";  | 
              |
| 8 | 
                  -plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"  | 
              |
| 9 | 
                  - if $@;  | 
              |
| 10 | 
                  -  | 
              |
| 11 | 
                  -# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,  | 
              |
| 12 | 
                  -# but older versions don't recognize some common documentation styles  | 
              |
| 13 | 
                  -my $min_pc = 0.18;  | 
              |
| 14 | 
                  -eval "use Pod::Coverage $min_pc";  | 
              |
| 15 | 
                  -plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"  | 
              |
| 16 | 
                  - if $@;  | 
              |
| 17 | 
                  -  | 
              |
| 18 | 
                  -all_pod_coverage_ok({also_private => [qr/default_bind_filter|default_fetch_filter|default_filter/]});
                 |