| ... | ... | 
                  @@ -9,3 +9,4 @@ blib/*  | 
              
| 9 | 9 | 
                  *.tar.gz  | 
              
| 10 | 10 | 
                  cover_db/*  | 
              
| 11 | 11 | 
                  *.tmp  | 
              
| 12 | 
                  +t/*.db  | 
              
| ... | ... | 
                  @@ -1,3 +1,8 @@  | 
              
| 1 | 
                  +0.1612  | 
              |
| 2 | 
                  + add tests  | 
              |
| 3 | 
                  + updated document  | 
              |
| 4 | 
                  + removed DBIx::Custom::SQLite last_insert_rawid() mehtod(not backword compatible)  | 
              |
| 5 | 
                  + removed DBIx::Custom::MySQL last_insert_id() method(not backword compatible)  | 
              |
| 1 | 6 | 
                  0.1611  | 
              
| 2 | 7 | 
                  renamed update tag to update_param  | 
              
| 3 | 8 | 
                  renamed insert tag to insert_param  | 
              
| ... | ... | 
                  @@ -13,3 +13,4 @@  | 
              
| 13 | 13 | 
                  \.gz$  | 
              
| 14 | 14 | 
                  ^\.git  | 
              
| 15 | 15 | 
                  ^cover_db/  | 
              
| 16 | 
                  +\.db$  | 
              
| ... | ... | 
                  @@ -93,7 +93,7 @@ sub insert {
                 | 
              
| 93 | 93 | 
                   | 
              
| 94 | 94 | 
                  # Check arguments  | 
              
| 95 | 95 | 
                       foreach my $name (keys %args) {
                 | 
              
| 96 | 
                  -        croak qq{"$name" is invalid name}
                 | 
              |
| 96 | 
                  +        croak qq{"$name" is invalid argument}
                 | 
              |
| 97 | 97 | 
                             unless $VALID_INSERT_ARGS{$name};
                 | 
              
| 98 | 98 | 
                  }  | 
              
| 99 | 99 | 
                   | 
              
| ... | ... | 
                  @@ -126,7 +126,7 @@ sub update {
                 | 
              
| 126 | 126 | 
                   | 
              
| 127 | 127 | 
                  # Check arguments  | 
              
| 128 | 128 | 
                       foreach my $name (keys %args) {
                 | 
              
| 129 | 
                  -        croak qq{"$name" is invalid name}
                 | 
              |
| 129 | 
                  +        croak qq{"$name" is invalid argument}
                 | 
              |
| 130 | 130 | 
                             unless $VALID_UPDATE_ARGS{$name};
                 | 
              
| 131 | 131 | 
                  }  | 
              
| 132 | 132 | 
                   | 
              
| ... | ... | 
                  @@ -134,7 +134,7 @@ sub update {
                 | 
              
| 134 | 134 | 
                       my $table            = $args{table} || '';
                 | 
              
| 135 | 135 | 
                       my $param            = $args{param} || {};
                 | 
              
| 136 | 136 | 
                       my $where            = $args{where} || {};
                 | 
              
| 137 | 
                  -    my $append_statement = $args{append} || '';
                 | 
              |
| 137 | 
                  +    my $append = $args{append} || '';
                 | 
              |
| 138 | 138 | 
                       my $filter           = $args{filter};
                 | 
              
| 139 | 139 | 
                       my $allow_update_all = $args{allow_update_all};
                 | 
              
| 140 | 140 | 
                   | 
              
| ... | ... | 
                  @@ -145,7 +145,8 @@ sub update {
                 | 
              
| 145 | 145 | 
                  my @where_keys = keys %$where;  | 
              
| 146 | 146 | 
                   | 
              
| 147 | 147 | 
                  # Not exists where keys  | 
              
| 148 | 
                  -    croak qq{"where" must contain the pairs of column name and value}
                 | 
              |
| 148 | 
                  +    croak qq{"where" argument must be specified and } .
                 | 
              |
| 149 | 
                  +          qq{contains the pairs of column name and value}
                 | 
              |
| 149 | 150 | 
                  if !@where_keys && !$allow_update_all;  | 
              
| 150 | 151 | 
                   | 
              
| 151 | 152 | 
                  # Update clause  | 
              
| ... | ... | 
                  @@ -157,16 +158,13 @@ sub update {
                 | 
              
| 157 | 158 | 
                   | 
              
| 158 | 159 | 
                       if (@where_keys) {
                 | 
              
| 159 | 160 | 
                  $where_clause = 'where ';  | 
              
| 160 | 
                  -        foreach my $where_key (@where_keys) {
                 | 
              |
| 161 | 
                  -  | 
              |
| 162 | 
                  -            $where_clause .= "{= $where_key} and ";
                 | 
              |
| 163 | 
                  - }  | 
              |
| 161 | 
                  +        $where_clause .= "{= $_} and " for @where_keys;
                 | 
              |
| 164 | 162 | 
                  $where_clause =~ s/ and $//;  | 
              
| 165 | 163 | 
                  }  | 
              
| 166 | 164 | 
                   | 
              
| 167 | 
                  - # Template for update  | 
              |
| 165 | 
                  + # Source of SQL  | 
              |
| 168 | 166 | 
                  my $source = "update $table $update_clause $where_clause";  | 
              
| 169 | 
                  - $source .= " $append_statement" if $append_statement;  | 
              |
| 167 | 
                  + $source .= " $append" if $append;  | 
              |
| 170 | 168 | 
                   | 
              
| 171 | 169 | 
                  # Rearrange parameters  | 
              
| 172 | 170 | 
                       foreach my $wkey (@where_keys) {
                 | 
              
| ... | ... | 
                  @@ -184,7 +182,7 @@ sub update {
                 | 
              
| 184 | 182 | 
                   | 
              
| 185 | 183 | 
                  # Execute query  | 
              
| 186 | 184 | 
                  my $ret_val = $self->execute($source, param => $param,  | 
              
| 187 | 
                  - filter => $filter);  | 
              |
| 185 | 
                  + filter => $filter);  | 
              |
| 188 | 186 | 
                   | 
              
| 189 | 187 | 
                  return $ret_val;  | 
              
| 190 | 188 | 
                  }  | 
              
| ... | ... | 
                  @@ -199,14 +197,14 @@ sub delete {
                 | 
              
| 199 | 197 | 
                   | 
              
| 200 | 198 | 
                  # Check arguments  | 
              
| 201 | 199 | 
                       foreach my $name (keys %args) {
                 | 
              
| 202 | 
                  -        croak qq{"$name" is invalid name}
                 | 
              |
| 200 | 
                  +        croak qq{"$name" is invalid argument}
                 | 
              |
| 203 | 201 | 
                             unless $VALID_DELETE_ARGS{$name};
                 | 
              
| 204 | 202 | 
                  }  | 
              
| 205 | 203 | 
                   | 
              
| 206 | 204 | 
                  # Arguments  | 
              
| 207 | 205 | 
                       my $table            = $args{table} || '';
                 | 
              
| 208 | 206 | 
                       my $where            = $args{where} || {};
                 | 
              
| 209 | 
                  -    my $append_statement = $args{append};
                 | 
              |
| 207 | 
                  +    my $append = $args{append};
                 | 
              |
| 210 | 208 | 
                       my $filter           = $args{filter};
                 | 
              
| 211 | 209 | 
                       my $allow_delete_all = $args{allow_delete_all};
                 | 
              
| 212 | 210 | 
                   | 
              
| ... | ... | 
                  @@ -214,26 +212,25 @@ sub delete {
                 | 
              
| 214 | 212 | 
                  my @where_keys = keys %$where;  | 
              
| 215 | 213 | 
                   | 
              
| 216 | 214 | 
                  # Not exists where keys  | 
              
| 217 | 
                  -    croak qq{Key-value pairs for where clause must be specified to "delete" second argument}
                 | 
              |
| 215 | 
                  +    croak qq{"where" argument must be specified and } .
                 | 
              |
| 216 | 
                  +          qq{contains the pairs of column name and value}
                 | 
              |
| 218 | 217 | 
                  if !@where_keys && !$allow_delete_all;  | 
              
| 219 | 218 | 
                   | 
              
| 220 | 219 | 
                  # Where clause  | 
              
| 221 | 220 | 
                  my $where_clause = '';  | 
              
| 222 | 221 | 
                       if (@where_keys) {
                 | 
              
| 223 | 222 | 
                  $where_clause = 'where ';  | 
              
| 224 | 
                  -        foreach my $wkey (@where_keys) {
                 | 
              |
| 225 | 
                  -            $where_clause .= "{= $wkey} and ";
                 | 
              |
| 226 | 
                  - }  | 
              |
| 223 | 
                  +        $where_clause .= "{= $_} and " for @where_keys;
                 | 
              |
| 227 | 224 | 
                  $where_clause =~ s/ and $//;  | 
              
| 228 | 225 | 
                  }  | 
              
| 229 | 226 | 
                   | 
              
| 230 | 
                  - # Template for delete  | 
              |
| 227 | 
                  + # Source of SQL  | 
              |
| 231 | 228 | 
                  my $source = "delete from $table $where_clause";  | 
              
| 232 | 
                  - $source .= " $append_statement" if $append_statement;  | 
              |
| 229 | 
                  + $source .= " $append" if $append;  | 
              |
| 233 | 230 | 
                   | 
              
| 234 | 231 | 
                  # Execute query  | 
              
| 235 | 232 | 
                  my $ret_val = $self->execute($source, param => $where,  | 
              
| 236 | 
                  - filter => $filter);  | 
              |
| 233 | 
                  + filter => $filter);  | 
              |
| 237 | 234 | 
                   | 
              
| 238 | 235 | 
                  return $ret_val;  | 
              
| 239 | 236 | 
                  }  | 
              
| ... | ... | 
                  @@ -248,7 +245,7 @@ sub select {
                 | 
              
| 248 | 245 | 
                   | 
              
| 249 | 246 | 
                  # Check arguments  | 
              
| 250 | 247 | 
                       foreach my $name (keys %args) {
                 | 
              
| 251 | 
                  -        croak qq{"$name" is invalid name}
                 | 
              |
| 248 | 
                  +        croak qq{"$name" is invalid argument}
                 | 
              |
| 252 | 249 | 
                             unless $VALID_SELECT_ARGS{$name};
                 | 
              
| 253 | 250 | 
                  }  | 
              
| 254 | 251 | 
                   | 
              
| ... | ... | 
                  @@ -261,7 +258,7 @@ sub select {
                 | 
              
| 261 | 258 | 
                       my $append   = $args{append};
                 | 
              
| 262 | 259 | 
                       my $filter   = $args{filter};
                 | 
              
| 263 | 260 | 
                   | 
              
| 264 | 
                  - # SQL template for select statement  | 
              |
| 261 | 
                  + # Source of SQL  | 
              |
| 265 | 262 | 
                  my $source = 'select ';  | 
              
| 266 | 263 | 
                   | 
              
| 267 | 264 | 
                  # Column clause  | 
              
| ... | ... | 
                  @@ -342,9 +339,10 @@ sub create_query {
                 | 
              
| 342 | 339 | 
                  my $builder = $self->query_builder;  | 
              
| 343 | 340 | 
                   | 
              
| 344 | 341 | 
                  # Create query  | 
              
| 345 | 
                  -        $query = eval{$builder->build_query($source)};
                 | 
              |
| 346 | 
                  - croak $@ if $@;  | 
              |
| 347 | 
                  -  | 
              |
| 342 | 
                  +        {
                 | 
              |
| 343 | 
                  + local $Carp::CarpLevel += 1;  | 
              |
| 344 | 
                  + $query = $builder->build_query($source);  | 
              |
| 345 | 
                  + }  | 
              |
| 348 | 346 | 
                  # Cache query  | 
              
| 349 | 347 | 
                  $self->cache_method->($self, $source,  | 
              
| 350 | 348 | 
                                                {sql     => $query->sql, 
                 | 
              
| ... | ... | 
                  @@ -353,8 +351,13 @@ sub create_query {
                 | 
              
| 353 | 351 | 
                  }  | 
              
| 354 | 352 | 
                   | 
              
| 355 | 353 | 
                  # Prepare statement handle  | 
              
| 356 | 
                  -    my $sth = eval {$self->dbh->prepare($query->{sql})};
                 | 
              |
| 357 | 
                  -    croak qq{$@ SQL: "$query->{sql}"} if $@;
                 | 
              |
| 354 | 
                  + my $sth;  | 
              |
| 355 | 
                  +    eval { $sth = $self->dbh->prepare($query->{sql})};
                 | 
              |
| 356 | 
                  +    if ($@) {
                 | 
              |
| 357 | 
                  + my $error = $@;  | 
              |
| 358 | 
                  + $error =~ s/\s+at\s+.*?\s+line\s+\d+.*$//s;  | 
              |
| 359 | 
                  +        croak qq{$error. SQL: "$query->{sql}"};
                 | 
              |
| 360 | 
                  + }  | 
              |
| 358 | 361 | 
                   | 
              
| 359 | 362 | 
                  # Set statement handle  | 
              
| 360 | 363 | 
                  $query->sth($sth);  | 
              
| ... | ... | 
                  @@ -369,13 +372,13 @@ sub execute{
                 | 
              
| 369 | 372 | 
                   | 
              
| 370 | 373 | 
                  # Check arguments  | 
              
| 371 | 374 | 
                       foreach my $name (keys %args) {
                 | 
              
| 372 | 
                  -        croak qq{"$name" is invalid name}
                 | 
              |
| 375 | 
                  +        croak qq{"$name" is invalid argument}
                 | 
              |
| 373 | 376 | 
                             unless $VALID_EXECUTE_ARGS{$name};
                 | 
              
| 374 | 377 | 
                  }  | 
              
| 375 | 378 | 
                   | 
              
| 376 | 379 | 
                       my $params = $args{param} || {};
                 | 
              
| 377 | 380 | 
                   | 
              
| 378 | 
                  - # First argument is SQL template  | 
              |
| 381 | 
                  + # First argument is the soruce of SQL  | 
              |
| 379 | 382 | 
                  $query = $self->create_query($query)  | 
              
| 380 | 383 | 
                  unless ref $query;  | 
              
| 381 | 384 | 
                   | 
              
| ... | ... | 
                  @@ -386,8 +389,13 @@ sub execute{
                 | 
              
| 386 | 389 | 
                   | 
              
| 387 | 390 | 
                  # Execute  | 
              
| 388 | 391 | 
                  my $sth = $query->sth;  | 
              
| 389 | 
                  -    my $affected = eval {$sth->execute(@$bind_values)};
                 | 
              |
| 390 | 
                  - croak $@ if $@;  | 
              |
| 392 | 
                  + my $affected;  | 
              |
| 393 | 
                  +    eval {$affected = $sth->execute(@$bind_values)};
                 | 
              |
| 394 | 
                  +    if ($@) {
                 | 
              |
| 395 | 
                  + my $error = $@;  | 
              |
| 396 | 
                  + $error =~ s/\s+at\s+.*?\s+line\s+\d+.*$//s;  | 
              |
| 397 | 
                  + croak $error;  | 
              |
| 398 | 
                  + }  | 
              |
| 391 | 399 | 
                   | 
              
| 392 | 400 | 
                  # Return resultset if select statement is executed  | 
              
| 393 | 401 | 
                       if ($sth->{NUM_OF_FIELDS}) {
                 | 
              
| ... | ... | 
                  @@ -426,31 +434,14 @@ sub _build_bind_values {
                 | 
              
| 426 | 434 | 
                       my $count = {};
                 | 
              
| 427 | 435 | 
                       foreach my $column (@{$query->columns}) {
                 | 
              
| 428 | 436 | 
                   | 
              
| 429 | 
                  -        croak qq{"$column" is not exists in params}
                 | 
              |
| 430 | 
                  -          unless exists $params->{$column};
                 | 
              |
| 431 | 
                  -  | 
              |
| 432 | 437 | 
                  # Value  | 
              
| 433 | 438 | 
                           my $value = ref $params->{$column} eq 'ARRAY'
                 | 
              
| 434 | 439 | 
                                     ? $params->{$column}->[$count->{$column} || 0]
                 | 
              
| 435 | 440 | 
                                     : $params->{$column};
                 | 
              
| 436 | 441 | 
                   | 
              
| 437 | 
                  - # Filter name  | 
              |
| 442 | 
                  + # Filtering  | 
              |
| 438 | 443 | 
                           my $fname = $filter->{$column} || $self->default_bind_filter || '';
                 | 
              
| 439 | 
                  -  | 
              |
| 440 | 
                  - my $filter_func;  | 
              |
| 441 | 
                  -        if ($fname) {
                 | 
              |
| 442 | 
                  -  | 
              |
| 443 | 
                  -            if (ref $fname eq 'CODE') {
                 | 
              |
| 444 | 
                  - $filter_func = $fname;  | 
              |
| 445 | 
                  - }  | 
              |
| 446 | 
                  -            else {
                 | 
              |
| 447 | 
                  - my $filters = $self->filters;  | 
              |
| 448 | 
                  -                croak qq{Not exists filter "$fname"}
                 | 
              |
| 449 | 
                  -                  unless exists $filters->{$fname};
                 | 
              |
| 450 | 
                  -                $filter_func = $filters->{$fname};
                 | 
              |
| 451 | 
                  - }  | 
              |
| 452 | 
                  - }  | 
              |
| 453 | 
                  -  | 
              |
| 444 | 
                  +        my $filter_func = $fname ? $self->filters->{$fname} : undef;
                 | 
              |
| 454 | 445 | 
                  push @bind_values, $filter_func  | 
              
| 455 | 446 | 
                  ? $filter_func->($value)  | 
              
| 456 | 447 | 
                  : $value;  | 
              
| ... | ... | 
                  @@ -489,7 +480,7 @@ DBIx::Custom - DBI interface, having hash parameter binding and filtering system  | 
              
| 489 | 480 | 
                   | 
              
| 490 | 481 | 
                  =cut  | 
              
| 491 | 482 | 
                   | 
              
| 492 | 
                  -our $VERSION = '0.1611';  | 
              |
| 483 | 
                  +our $VERSION = '0.1612';  | 
              |
| 493 | 484 | 
                   | 
              
| 494 | 485 | 
                  =head1 STABILITY  | 
              
| 495 | 486 | 
                   | 
              
| ... | ... | 
                  @@ -28,8 +28,6 @@ sub connect {
                 | 
              
| 28 | 28 | 
                  return $self->SUPER::connect;  | 
              
| 29 | 29 | 
                  }  | 
              
| 30 | 30 | 
                   | 
              
| 31 | 
                  -sub last_insert_id { shift->dbh->{mysql_insertid} }
                 | 
              |
| 32 | 
                  -  | 
              |
| 33 | 31 | 
                  1;  | 
              
| 34 | 32 | 
                   | 
              
| 35 | 33 | 
                  =head1 NAME  | 
              
| ... | ... | 
                  @@ -100,11 +98,4 @@ This method overrides C<DBIx::Custom::connect()> method.  | 
              
| 100 | 98 | 
                  You can specify all attributes of L<DBIx::Custom>  | 
              
| 101 | 99 | 
                  and L<DBIx::Custom::MySQL>, such as C<database>, C<host>, C<port>.  | 
              
| 102 | 100 | 
                   | 
              
| 103 | 
                  -=head2 C<last_insert_id>  | 
              |
| 104 | 
                  -  | 
              |
| 105 | 
                  - my $last_insert_id = $dbi->last_insert_id;  | 
              |
| 106 | 
                  -  | 
              |
| 107 | 
                  -Get last insert id.  | 
              |
| 108 | 
                  -This is same as C<last_insert_id()> function in MySQL.  | 
              |
| 109 | 
                  -  | 
              |
| 110 | 101 | 
                  =cut  | 
              
| ... | ... | 
                  @@ -137,7 +137,11 @@ sub _build_query {
                 | 
              
| 137 | 137 | 
                  unless ref $tag_processor eq 'CODE';  | 
              
| 138 | 138 | 
                   | 
              
| 139 | 139 | 
                  # Execute tag processor  | 
              
| 140 | 
                  - my $r = $tag_processor->(@$tag_args);  | 
              |
| 140 | 
                  + my $r;  | 
              |
| 141 | 
                  +            {
                 | 
              |
| 142 | 
                  + local $Carp::CarpLevel += 1;  | 
              |
| 143 | 
                  + $r = $tag_processor->(@$tag_args);  | 
              |
| 144 | 
                  + }  | 
              |
| 141 | 145 | 
                   | 
              
| 142 | 146 | 
                  # Check tag processor return value  | 
              
| 143 | 147 | 
                               croak qq{Tag processor "$tag_name" must return [STRING, ARRAY_REFERENCE]}
                 | 
              
| ... | ... | 
                  @@ -27,7 +27,7 @@ sub expand_placeholder_tag {
                 | 
              
| 27 | 27 | 
                  my $column = shift;  | 
              
| 28 | 28 | 
                   | 
              
| 29 | 29 | 
                  # Check arguments  | 
              
| 30 | 
                  -    croak qq{Column must be specified in tag "{? }"}
                 | 
              |
| 30 | 
                  +    croak qq{Column name must be specified in tag "{? }"}
                 | 
              |
| 31 | 31 | 
                  unless $column;  | 
              
| 32 | 32 | 
                   | 
              
| 33 | 33 | 
                  return ['?', [$column]];  | 
              
| ... | ... | 
                  @@ -14,8 +14,9 @@ sub connect {
                 | 
              
| 14 | 14 | 
                  my $self = ref $proto ? $proto : $proto->new(@_);  | 
              
| 15 | 15 | 
                   | 
              
| 16 | 16 | 
                  # Data source  | 
              
| 17 | 
                  -    if (!$self->data_source && (my $database = $self->database)) {
                 | 
              |
| 18 | 
                  -        $self->data_source("dbi:SQLite:dbname=$database");
                 | 
              |
| 17 | 
                  + my $database = $self->database;  | 
              |
| 18 | 
                  +    if (!$self->data_source && $database) {
                 | 
              |
| 19 | 
                  +        $self->data_source("dbi:SQLite:dbname=$database")
                 | 
              |
| 19 | 20 | 
                  }  | 
              
| 20 | 21 | 
                   | 
              
| 21 | 22 | 
                  return $self->SUPER::connect;  | 
              
| ... | ... | 
                  @@ -33,8 +34,6 @@ sub connect_memory {
                 | 
              
| 33 | 34 | 
                  return $self;  | 
              
| 34 | 35 | 
                  }  | 
              
| 35 | 36 | 
                   | 
              
| 36 | 
                  -sub last_insert_rowid { shift->dbh->func('last_insert_rowid') }
                 | 
              |
| 37 | 
                  -  | 
              |
| 38 | 37 | 
                  1;  | 
              
| 39 | 38 | 
                   | 
              
| 40 | 39 | 
                  =head1 NAME  | 
              
| ... | ... | 
                  @@ -88,11 +87,4 @@ and L<DBIx::Custom::SQLite>, such as C<database>.  | 
              
| 88 | 87 | 
                   | 
              
| 89 | 88 | 
                  Create a new L<DBIx::Custom::SQLite> object and connect to the memory database.  | 
              
| 90 | 89 | 
                   | 
              
| 91 | 
                  -=head2 C<last_insert_rowid>  | 
              |
| 92 | 
                  -  | 
              |
| 93 | 
                  - my $last_insert_rowid = $dbi->last_insert_rowid;  | 
              |
| 94 | 
                  -  | 
              |
| 95 | 
                  -Get last insert row id.  | 
              |
| 96 | 
                  -This is same as C<last_insert_rowid()> function in SQLite.  | 
              |
| 97 | 
                  -  | 
              |
| 98 | 90 | 
                  =cut  | 
              
| ... | ... | 
                  @@ -28,7 +28,7 @@ my $CREATE_TABLE = {
                 | 
              
| 28 | 28 | 
                  2 => 'create table table2 (key1 char(255), key3 char(255));'  | 
              
| 29 | 29 | 
                  };  | 
              
| 30 | 30 | 
                   | 
              
| 31 | 
                  -my $SELECT_TMPLS = {
                 | 
              |
| 31 | 
                  +my $SELECT_SOURCES = {
                 | 
              |
| 32 | 32 | 
                  0 => 'select * from table1;'  | 
              
| 33 | 33 | 
                  };  | 
              
| 34 | 34 | 
                   | 
              
| ... | ... | 
                  @@ -45,9 +45,9 @@ my $dbi;  | 
              
| 45 | 45 | 
                  my $sth;  | 
              
| 46 | 46 | 
                  my $source;  | 
              
| 47 | 47 | 
                  my @sources;  | 
              
| 48 | 
                  -my $select_tmpl;  | 
              |
| 49 | 
                  -my $insert_tmpl;  | 
              |
| 50 | 
                  -my $update_tmpl;  | 
              |
| 48 | 
                  +my $select_SOURCE;  | 
              |
| 49 | 
                  +my $insert_SOURCE;  | 
              |
| 50 | 
                  +my $update_SOURCE;  | 
              |
| 51 | 51 | 
                  my $params;  | 
              
| 52 | 52 | 
                  my $sql;  | 
              
| 53 | 53 | 
                  my $result;  | 
              
| ... | ... | 
                  @@ -106,9 +106,9 @@ ok($ret_val, $test);  | 
              
| 106 | 106 | 
                  test 'Direct query';  | 
              
| 107 | 107 | 
                   $dbi->execute($DROP_TABLE->{0});
                 | 
              
| 108 | 108 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 109 | 
                  -$insert_tmpl = "insert into table1 {insert_param key1 key2}";
                 | 
              |
| 110 | 
                  -$dbi->execute($insert_tmpl, param => {key1 => 1, key2 => 2});
                 | 
              |
| 111 | 
                  -$result = $dbi->execute($SELECT_TMPLS->{0});
                 | 
              |
| 109 | 
                  +$insert_SOURCE = "insert into table1 {insert_param key1 key2}";
                 | 
              |
| 110 | 
                  +$dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2});
                 | 
              |
| 111 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 112 | 112 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 113 | 113 | 
                   is_deeply($rows, [{key1 => 1, key2 => 2}], $test);
                 | 
              
| 114 | 114 | 
                   | 
              
| ... | ... | 
                  @@ -118,22 +118,22 @@ $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 118 | 118 | 
                   $dbi->register_filter(twice       => sub { $_[0] * 2}, 
                 | 
              
| 119 | 119 | 
                                       three_times => sub { $_[0] * 3});
                 | 
              
| 120 | 120 | 
                   | 
              
| 121 | 
                  -$insert_tmpl  = "insert into table1 {insert_param key1 key2};";
                 | 
              |
| 122 | 
                  -$insert_query = $dbi->create_query($insert_tmpl);  | 
              |
| 121 | 
                  +$insert_SOURCE  = "insert into table1 {insert_param key1 key2};";
                 | 
              |
| 122 | 
                  +$insert_query = $dbi->create_query($insert_SOURCE);  | 
              |
| 123 | 123 | 
                   $insert_query->filter({key1 => 'twice'});
                 | 
              
| 124 | 124 | 
                   $dbi->execute($insert_query, param => {key1 => 1, key2 => 2});
                 | 
              
| 125 | 
                  -$result = $dbi->execute($SELECT_TMPLS->{0});
                 | 
              |
| 125 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 126 | 126 | 
                   $rows = $result->filter({key2 => 'three_times'})->fetch_hash_all;
                 | 
              
| 127 | 127 | 
                   is_deeply($rows, [{key1 => 2, key2 => 6}], "$test : filter fetch_filter");
                 | 
              
| 128 | 128 | 
                   $dbi->execute($DROP_TABLE->{0});
                 | 
              
| 129 | 129 | 
                   | 
              
| 130 | 130 | 
                  test 'Filter in';  | 
              
| 131 | 131 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 132 | 
                  -$insert_tmpl  = "insert into table1 {insert_param key1 key2};";
                 | 
              |
| 133 | 
                  -$insert_query = $dbi->create_query($insert_tmpl);  | 
              |
| 132 | 
                  +$insert_SOURCE  = "insert into table1 {insert_param key1 key2};";
                 | 
              |
| 133 | 
                  +$insert_query = $dbi->create_query($insert_SOURCE);  | 
              |
| 134 | 134 | 
                   $dbi->execute($insert_query, param => {key1 => 2, key2 => 4});
                 | 
              
| 135 | 
                  -$select_tmpl = "select * from table1 where {in table1.key1 2} and {in table1.key2 2}";
                 | 
              |
| 136 | 
                  -$select_query = $dbi->create_query($select_tmpl);  | 
              |
| 135 | 
                  +$select_SOURCE = "select * from table1 where {in table1.key1 2} and {in table1.key2 2}";
                 | 
              |
| 136 | 
                  +$select_query = $dbi->create_query($select_SOURCE);  | 
              |
| 137 | 137 | 
                   $select_query->filter({'table1.key1' => 'twice'});
                 | 
              
| 138 | 138 | 
                   $result = $dbi->execute($select_query, param => {'table1.key1' => [1,5], 'table1.key2' => [2,4]});
                 | 
              
| 139 | 139 | 
                  $rows = $result->fetch_hash_all;  | 
              
| ... | ... | 
                  @@ -171,23 +171,23 @@ is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$te
                 | 
              
| 171 | 171 | 
                   | 
              
| 172 | 172 | 
                  test 'DBIx::Custom::SQLTemplate insert tag';  | 
              
| 173 | 173 | 
                   $dbi->execute("delete from table1");
                 | 
              
| 174 | 
                  -$insert_tmpl = 'insert into table1 {insert_param key1 key2 key3 key4 key5}';
                 | 
              |
| 175 | 
                  -$dbi->execute($insert_tmpl, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
                 | 
              |
| 174 | 
                  +$insert_SOURCE = 'insert into table1 {insert_param key1 key2 key3 key4 key5}';
                 | 
              |
| 175 | 
                  +$dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
                 | 
              |
| 176 | 176 | 
                   | 
              
| 177 | 
                  -$result = $dbi->execute($SELECT_TMPLS->{0});
                 | 
              |
| 177 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 178 | 178 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 179 | 179 | 
                   is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic");
                 | 
              
| 180 | 180 | 
                   | 
              
| 181 | 181 | 
                  test 'DBIx::Custom::SQLTemplate update tag';  | 
              
| 182 | 182 | 
                   $dbi->execute("delete from table1");
                 | 
              
| 183 | 
                  -$insert_tmpl = "insert into table1 {insert_param key1 key2 key3 key4 key5}";
                 | 
              |
| 184 | 
                  -$dbi->execute($insert_tmpl, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
                 | 
              |
| 185 | 
                  -$dbi->execute($insert_tmpl, param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
                 | 
              |
| 183 | 
                  +$insert_SOURCE = "insert into table1 {insert_param key1 key2 key3 key4 key5}";
                 | 
              |
| 184 | 
                  +$dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
                 | 
              |
| 185 | 
                  +$dbi->execute($insert_SOURCE, param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
                 | 
              |
| 186 | 186 | 
                   | 
              
| 187 | 
                  -$update_tmpl = 'update table1 {update_param key1 key2 key3 key4} where {= key5}';
                 | 
              |
| 188 | 
                  -$dbi->execute($update_tmpl, param => {key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5});
                 | 
              |
| 187 | 
                  +$update_SOURCE = 'update table1 {update_param key1 key2 key3 key4} where {= key5}';
                 | 
              |
| 188 | 
                  +$dbi->execute($update_SOURCE, param => {key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5});
                 | 
              |
| 189 | 189 | 
                   | 
              
| 190 | 
                  -$result = $dbi->execute($SELECT_TMPLS->{0});
                 | 
              |
| 190 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 191 | 191 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 192 | 192 | 
                   is_deeply($rows, [{key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5},
                 | 
              
| 193 | 193 | 
                                     {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : basic");
                 | 
              
| ... | ... | 
                  @@ -205,7 +205,7 @@ $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| 205 | 205 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 206 | 206 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              
| 207 | 207 | 
                   $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
                 | 
              
| 208 | 
                  -$result = $dbi->execute($SELECT_TMPLS->{0});
                 | 
              |
| 208 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 209 | 209 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 210 | 210 | 
                   is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "$test : basic");
                 | 
              
| 211 | 211 | 
                   | 
              
| ... | ... | 
                  @@ -216,7 +216,7 @@ $dbi->register_filter(  | 
              
| 216 | 216 | 
                  );  | 
              
| 217 | 217 | 
                   $dbi->default_bind_filter('twice');
                 | 
              
| 218 | 218 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, filter => {key1 => 'three_times'});
                 | 
              
| 219 | 
                  -$result = $dbi->execute($SELECT_TMPLS->{0});
                 | 
              |
| 219 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 220 | 220 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 221 | 221 | 
                   is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : filter");
                 | 
              
| 222 | 222 | 
                  $dbi->default_bind_filter(undef);  | 
              
| ... | ... | 
                  @@ -228,7 +228,7 @@ $rows = $dbi->select(table => 'table1')->fetch_hash_all;  | 
              
| 228 | 228 | 
                   is_deeply($rows, [{key1 => 1, key2 => 2}], 'insert append');
                 | 
              
| 229 | 229 | 
                   | 
              
| 230 | 230 | 
                   eval{$dbi->insert(table => 'table1', noexist => 1)};
                 | 
              
| 231 | 
                  -like($@, qr/noexist/, "$test: invalid name");  | 
              |
| 231 | 
                  +like($@, qr/noexist/, "$test: invalid argument");  | 
              |
| 232 | 232 | 
                   | 
              
| 233 | 233 | 
                   | 
              
| 234 | 234 | 
                  test 'update';  | 
              
| ... | ... | 
                  @@ -237,7 +237,7 @@ $dbi->execute($CREATE_TABLE->{1});
                 | 
              
| 237 | 237 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
                 | 
              
| 238 | 238 | 
                   $dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
                 | 
              
| 239 | 239 | 
                   $dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1});
                 | 
              
| 240 | 
                  -$result = $dbi->execute($SELECT_TMPLS->{0});
                 | 
              |
| 240 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 241 | 241 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 242 | 242 | 
                   is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
                 | 
              
| 243 | 243 | 
                                     {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
                 | 
              
| ... | ... | 
                  @@ -247,19 +247,26 @@ $dbi->execute("delete from table1");
                 | 
              
| 247 | 247 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
                 | 
              
| 248 | 248 | 
                   $dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
                 | 
              
| 249 | 249 | 
                   $dbi->update(table => 'table1', param => {key2 => 12}, where => {key2 => 2, key3 => 3});
                 | 
              
| 250 | 
                  -$result = $dbi->execute($SELECT_TMPLS->{0});
                 | 
              |
| 250 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 251 | 251 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 252 | 252 | 
                   is_deeply($rows, [{key1 => 1, key2 => 12, key3 => 3, key4 => 4, key5 => 5},
                 | 
              
| 253 | 253 | 
                                     {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
                 | 
              
| 254 | 254 | 
                  "$test : update key same as search key");  | 
              
| 255 | 255 | 
                   | 
              
| 256 | 
                  +$dbi->update(table => 'table1', param => {key2 => [12]}, where => {key2 => 2, key3 => 3});
                 | 
              |
| 257 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 258 | 
                  +$rows = $result->fetch_hash_all;  | 
              |
| 259 | 
                  +is_deeply($rows, [{key1 => 1, key2 => 12, key3 => 3, key4 => 4, key5 => 5},
                 | 
              |
| 260 | 
                  +                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
                 | 
              |
| 261 | 
                  + "$test : update key same as search key : param is array ref");  | 
              |
| 262 | 
                  +  | 
              |
| 256 | 263 | 
                   $dbi->execute("delete from table1");
                 | 
              
| 257 | 264 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
                 | 
              
| 258 | 265 | 
                   $dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
                 | 
              
| 259 | 266 | 
                   $dbi->register_filter(twice => sub { $_[0] * 2 });
                 | 
              
| 260 | 267 | 
                   $dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1},
                 | 
              
| 261 | 268 | 
                                 filter => {key2 => 'twice'});
                 | 
              
| 262 | 
                  -$result = $dbi->execute($SELECT_TMPLS->{0});
                 | 
              |
| 269 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 263 | 270 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 264 | 271 | 
                   is_deeply($rows, [{key1 => 1, key2 => 22, key3 => 3, key4 => 4, key5 => 5},
                 | 
              
| 265 | 272 | 
                                     {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
                 | 
              
| ... | ... | 
                  @@ -268,7 +275,7 @@ is_deeply($rows, [{key1 => 1, key2 => 22, key3 => 3, key4 => 4, key5 => 5},
                 | 
              
| 268 | 275 | 
                   $result = $dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1}, append => '   ');
                 | 
              
| 269 | 276 | 
                   | 
              
| 270 | 277 | 
                   eval{$dbi->update(table => 'table1', noexist => 1)};
                 | 
              
| 271 | 
                  -like($@, qr/noexist/, "$test: invalid name");  | 
              |
| 278 | 
                  +like($@, qr/noexist/, "$test: invalid argument");  | 
              |
| 272 | 279 | 
                   | 
              
| 273 | 280 | 
                   eval{$dbi->update(table => 'table1')};
                 | 
              
| 274 | 281 | 
                  like($@, qr/where/, "$test: not contain where");  | 
              
| ... | ... | 
                  @@ -281,7 +288,7 @@ $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4
                 | 
              
| 281 | 288 | 
                   $dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
                 | 
              
| 282 | 289 | 
                   $dbi->register_filter(twice => sub { $_[0] * 2 });
                 | 
              
| 283 | 290 | 
                   $dbi->update_all(table => 'table1', param => {key2 => 10}, filter => {key2 => 'twice'});
                 | 
              
| 284 | 
                  -$result = $dbi->execute($SELECT_TMPLS->{0});
                 | 
              |
| 291 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 285 | 292 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 286 | 293 | 
                   is_deeply($rows, [{key1 => 1, key2 => 20, key3 => 3, key4 => 4, key5 => 5},
                 | 
              
| 287 | 294 | 
                                     {key1 => 6, key2 => 20, key3 => 8, key4 => 9, key5 => 10}],
                 | 
              
| ... | ... | 
                  @@ -294,7 +301,7 @@ $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 294 | 301 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              
| 295 | 302 | 
                   $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
                 | 
              
| 296 | 303 | 
                   $dbi->delete(table => 'table1', where => {key1 => 1});
                 | 
              
| 297 | 
                  -$result = $dbi->execute($SELECT_TMPLS->{0});
                 | 
              |
| 304 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 298 | 305 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 299 | 306 | 
                   is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : basic");
                 | 
              
| 300 | 307 | 
                   | 
              
| ... | ... | 
                  @@ -303,7 +310,7 @@ $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              
| 303 | 310 | 
                   $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
                 | 
              
| 304 | 311 | 
                   $dbi->register_filter(twice => sub { $_[0] * 2 });
                 | 
              
| 305 | 312 | 
                   $dbi->delete(table => 'table1', where => {key2 => 1}, filter => {key2 => 'twice'});
                 | 
              
| 306 | 
                  -$result = $dbi->execute($SELECT_TMPLS->{0});
                 | 
              |
| 313 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 307 | 314 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 308 | 315 | 
                   is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : filter");
                 | 
              
| 309 | 316 | 
                   | 
              
| ... | ... | 
                  @@ -317,14 +324,14 @@ $rows = $dbi->select(table => 'table1')->fetch_hash_all;  | 
              
| 317 | 324 | 
                   is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : delete multi key");
                 | 
              
| 318 | 325 | 
                   | 
              
| 319 | 326 | 
                   eval{$dbi->delete(table => 'table1', noexist => 1)};
                 | 
              
| 320 | 
                  -like($@, qr/noexist/, "$test: invalid name");  | 
              |
| 327 | 
                  +like($@, qr/noexist/, "$test: invalid argument");  | 
              |
| 321 | 328 | 
                   | 
              
| 322 | 329 | 
                   | 
              
| 323 | 330 | 
                  test 'delete error';  | 
              
| 324 | 331 | 
                   $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              
| 325 | 332 | 
                   $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 326 | 333 | 
                   eval{$dbi->delete(table => 'table1')};
                 | 
              
| 327 | 
                  -like($@, qr/Key-value pairs for where clause must be specified to "delete" second argument/,  | 
              |
| 334 | 
                  +like($@, qr/"where" argument must be specified and contains the pairs of column name and value/,  | 
              |
| 328 | 335 | 
                  "$test : where key-value pairs not specified");  | 
              
| 329 | 336 | 
                   | 
              
| 330 | 337 | 
                  test 'delete_all';  | 
              
| ... | ... | 
                  @@ -333,7 +340,7 @@ $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 333 | 340 | 
                   $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              
| 334 | 341 | 
                   $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
                 | 
              
| 335 | 342 | 
                  $dbi->delete_all(table => 'table1');  | 
              
| 336 | 
                  -$result = $dbi->execute($SELECT_TMPLS->{0});
                 | 
              |
| 343 | 
                  +$result = $dbi->execute($SELECT_SOURCES->{0});
                 | 
              |
| 337 | 344 | 
                  $rows = $result->fetch_hash_all;  | 
              
| 338 | 345 | 
                  is_deeply($rows, [], "$test : basic");  | 
              
| 339 | 346 | 
                   | 
              
| ... | ... | 
                  @@ -385,7 +392,7 @@ $rows = $dbi->select(  | 
              
| 385 | 392 | 
                   is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "$test : relation : no exists where");
                 | 
              
| 386 | 393 | 
                   | 
              
| 387 | 394 | 
                   eval{$dbi->select(table => 'table1', noexist => 1)};
                 | 
              
| 388 | 
                  -like($@, qr/noexist/, "$test: invalid name");  | 
              |
| 395 | 
                  +like($@, qr/noexist/, "$test: invalid argument");  | 
              |
| 389 | 396 | 
                   | 
              
| 390 | 397 | 
                   | 
              
| 391 | 398 | 
                  test 'fetch filter';  | 
              
| ... | ... | 
                  @@ -530,3 +537,20 @@ eval{$dbi->select(table => 'table1', filter => {not_exists => 'encode_utf8'})};
                 | 
              
| 530 | 537 | 
                  like($@, qr/\QColumn name "not_exists" in bind filter is not found in paramters/,  | 
              
| 531 | 538 | 
                  "$test : fetch_filter");  | 
              
| 532 | 539 | 
                   | 
              
| 540 | 
                  +test 'execute';  | 
              |
| 541 | 
                  +$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
                 | 
              |
| 542 | 
                  +$dbi->execute($CREATE_TABLE->{0});
                 | 
              |
| 543 | 
                  +eval{$dbi->execute('select * frm table1')};
                 | 
              |
| 544 | 
                  +like($@, qr/\Qselect * frm table1;/, "$test : fail prepare");  | 
              |
| 545 | 
                  +  | 
              |
| 546 | 
                  +eval{$dbi->execute('select * from table1', no_exists => 1)};
                 | 
              |
| 547 | 
                  +like($@, qr/\Q"no_exists" is invalid argument/, "$test : invald SQL");  | 
              |
| 548 | 
                  +  | 
              |
| 549 | 
                  +$query = $dbi->create_query('select * from table1 where {= key1}');
                 | 
              |
| 550 | 
                  +$dbi->dbh->disconnect;  | 
              |
| 551 | 
                  +eval{$dbi->execute($query, param => {key1 => {a => 1}})};
                 | 
              |
| 552 | 
                  +ok($@, "$test: execute fail");  | 
              |
| 553 | 
                  +  | 
              |
| 554 | 
                  +eval{$dbi->create_query('select * from table1 where {0 key1}')};
                 | 
              |
| 555 | 
                  +like($@, qr/\Q.t /, "$test : caller spec");  | 
              |
| 556 | 
                  +  | 
              
| ... | ... | 
                  @@ -30,18 +30,17 @@ sub connect_info {
                 | 
              
| 30 | 30 | 
                  }  | 
              
| 31 | 31 | 
                   | 
              
| 32 | 32 | 
                   | 
              
| 33 | 
                  -# Constat variables for tests  | 
              |
| 34 | 
                  -my $CLASS = 'DBIx::Custom::MySQL';  | 
              |
| 35 | 
                  -  | 
              |
| 36 | 33 | 
                  # Varialbes for tests  | 
              
| 37 | 34 | 
                  my $dbi;  | 
              
| 35 | 
                  +my $dbname;  | 
              |
| 38 | 36 | 
                   | 
              
| 39 | 37 | 
                  use DBIx::Custom::MySQL;  | 
              
| 40 | 38 | 
                   | 
              
| 41 | 39 | 
                  test 'connect';  | 
              
| 42 | 
                  -$dbi = $CLASS->new(user => $USER, password => $PASSWORD,  | 
              |
| 43 | 
                  - database => $DATABASE);  | 
              |
| 40 | 
                  +$dbi = DBIx::Custom::MySQL->new(user => $USER, password => $PASSWORD,  | 
              |
| 41 | 
                  + database => $DATABASE, host => 'localhost', port => '10000');  | 
              |
| 44 | 42 | 
                  $dbi->connect;  | 
              
| 43 | 
                  +like($dbi->data_source, qr/dbi:mysql:database=.*;host=localhost;port=10000;/, "$test : created data source");  | 
              |
| 45 | 44 | 
                  is(ref $dbi->dbh, 'DBI::db', $test);  | 
              
| 46 | 45 | 
                   | 
              
| 47 | 46 | 
                  test 'attributes';  | 
              
| ... | ... | 
                  @@ -84,6 +84,8 @@ isa_ok($ret_val, 'DBIx::Custom::QueryBuilder');  | 
              
| 84 | 84 | 
                  test "Tag processor error case";  | 
              
| 85 | 85 | 
                  $builder = DBIx::Custom::QueryBuilder->new;  | 
              
| 86 | 86 | 
                   | 
              
| 87 | 
                  +eval{$builder->build_query('{? }')};
                 | 
              |
| 88 | 
                  +like($@, qr/\QColumn name must be specified in tag "{? }"/, "$test : ? not arguments");
                 | 
              |
| 87 | 89 | 
                   | 
              
| 88 | 90 | 
                   eval{$builder->build_query("{a }")};
                 | 
              
| 89 | 91 | 
                   like($@, qr/\QTag "a" in "{a }" is not registered/, "$test : tag_processor not exist");
                 | 
              
| ... | ... | 
                  @@ -44,7 +44,7 @@ $dbh->do("insert into table1 (key1, key2) values ('3', '4');");
                 | 
              
| 44 | 44 | 
                   | 
              
| 45 | 45 | 
                  $sql = "select key1, key2 from table1";  | 
              
| 46 | 46 | 
                   | 
              
| 47 | 
                  -test 'fetch scalar context';  | 
              |
| 47 | 
                  +test 'fetch';  | 
              |
| 48 | 48 | 
                  $result = query($dbh, $sql);  | 
              
| 49 | 49 | 
                  @rows = ();  | 
              
| 50 | 50 | 
                   while (my $row = $result->fetch) {
                 | 
              
| ... | ... | 
                  @@ -53,7 +53,7 @@ while (my $row = $result->fetch) {
                 | 
              
| 53 | 53 | 
                  is_deeply(\@rows, [[1, 2], [3, 4]], $test);  | 
              
| 54 | 54 | 
                   | 
              
| 55 | 55 | 
                   | 
              
| 56 | 
                  -test 'fetch_hash scalar context';  | 
              |
| 56 | 
                  +test 'fetch_hash';  | 
              |
| 57 | 57 | 
                  $result = query($dbh, $sql);  | 
              
| 58 | 58 | 
                  @rows = ();  | 
              
| 59 | 59 | 
                   while (my $row = $result->fetch_hash) {
                 | 
              
| ... | ... | 
                  @@ -77,6 +77,11 @@ is_deeply($row, {key1 => 1, key2 => 2}, "$test : row");
                 | 
              
| 77 | 77 | 
                  $row = $result->fetch_hash;  | 
              
| 78 | 78 | 
                  ok(!$row, "$test : finished");  | 
              
| 79 | 79 | 
                   | 
              
| 80 | 
                  +$result = query($dbh, 'create table table2 (key1, key2);');  | 
              |
| 81 | 
                  +$result = query($dbh, 'select * from table2');  | 
              |
| 82 | 
                  +$row = $result->fetch_hash_first;  | 
              |
| 83 | 
                  +ok(!$row, "$test : no row fetch");  | 
              |
| 84 | 
                  +  | 
              |
| 80 | 85 | 
                   | 
              
| 81 | 86 | 
                  test 'fetch_multi';  | 
              
| 82 | 87 | 
                   $dbh->do("insert into table1 (key1, key2) values ('5', '6');");
                 | 
              
| ... | ... | 
                  @@ -51,13 +51,11 @@ ok(-f $db_file, "$test : database file");  | 
              
| 51 | 51 | 
                   $ret_val = $dbi->execute($CREATE_TABLE->{0});
                 | 
              
| 52 | 52 | 
                  ok(defined $ret_val, "$test : database");  | 
              
| 53 | 53 | 
                  $dbi->dbh->disconnect;  | 
              
| 54 | 
                  +  | 
              |
| 54 | 55 | 
                  unlink $db_file if -f $db_file;  | 
              
| 56 | 
                  +$dbi = DBIx::Custom::SQLite->connect(database => $db_file);  | 
              |
| 57 | 
                  +ok($dbi, "$test : called from class name");  | 
              |
| 55 | 58 | 
                   | 
              
| 56 | 
                  -test 'last_insert_rowid';  | 
              |
| 57 | 
                  -$dbi = DBIx::Custom::SQLite->connect_memory;  | 
              |
| 58 | 
                  -$ret_val = $dbi->execute($CREATE_TABLE->{0});
                 | 
              |
| 59 | 
                  -$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              |
| 60 | 
                  -is($dbi->last_insert_rowid, 1, "$test: first");  | 
              |
| 61 | 
                  -$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
                 | 
              |
| 62 | 
                  -is($dbi->last_insert_rowid, 2, "$test: second");  | 
              |
| 63 | 
                  -$dbi->dbh->disconnect;  | 
              |
| 59 | 
                  +unlink $db_file if -f $db_file;  | 
              |
| 60 | 
                  +$dbi = DBIx::Custom::SQLite->connect(data_source => "dbi:SQLite:dbname=$db_file");  | 
              |
| 61 | 
                  +ok($dbi, "$test : specified data source");  |