| 
                  ...
                 | 
                
                  ...
                 | 
                
                  @@ -47,6 +47,11 @@ my $ret_val; 
                 | 
              
              
              
                | 
                  47
                 | 
                
                  47
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  48
                 | 
                
                  48
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  49
                 | 
                
                  49
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  50
                 | 
                
                  +test 'Disconnect';
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  51
                 | 
                
                  +$dbi = DBI::Custom->new(data_source => 'dbi:SQLite:dbname=:memory:');
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  52
                 | 
                
                  +$dbi->connect;
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  53
                 | 
                
                  +$dbi->disconnect;
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  54
                 | 
                
                  +ok(!$dbi->dbh, $test);
 
                 | 
              
              
              
                | 
                  50
                 | 
                
                  55
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  51
                 | 
                
                  56
                 | 
                
                   # Prepare table
 
                 | 
              
              
              
                | 
                  52
                 | 
                
                  57
                 | 
                
                   $dbi = DBI::Custom->new(data_source => 'dbi:SQLite:dbname=:memory:');
 
                 | 
              
              
              
                | 
                  ...
                 | 
                
                  ...
                 | 
                
                  @@ -216,12 +221,40 @@ $result = $dbi->execute($query, {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key
                 | 
              
              
              
                | 
                  216
                 | 
                
                  221
                 | 
                
                   $rows = $result->fetch_all_hash;
 
                 | 
              
              
              
                | 
                  217
                 | 
                
                  222
                 | 
                
                   is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag1");
                 | 
              
              
              
                | 
                  218
                 | 
                
                  223
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  224
                 | 
                
                  +$tmpl = "select * from table1 where {= table1.key1} and {<> table1.key2} and {< table1.key3} and {> table1.key4} and {>= table1.key5};";
                 | 
              
              
              
                | 
                  
                 | 
                
                  225
                 | 
                
                  +$query = $dbi->create_query($tmpl);
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  226
                 | 
                
                  +$result = $dbi->execute($query, {table1 => {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key5 => 5}});
                 | 
              
              
              
                | 
                  
                 | 
                
                  227
                 | 
                
                  +$rows = $result->fetch_all_hash;
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  228
                 | 
                
                  +is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag1 with table");
                 | 
              
              
              
                | 
                  
                 | 
                
                  229
                 | 
                
                  +
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  230
                 | 
                
                  +$tmpl = "select * from table1 where {= table1.key1} and {<> table1.key2} and {< table1.key3} and {> table1.key4} and {>= table1.key5};";
                 | 
              
              
              
                | 
                  
                 | 
                
                  231
                 | 
                
                  +$query = $dbi->create_query($tmpl);
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  232
                 | 
                
                  +$result = $dbi->execute($query, {'table1.key1' => 1, 'table1.key2' => 3, 'table1.key3' => 4, 'table1.key4' => 3, 'table1.key5' => 5});
                 | 
              
              
              
                | 
                  
                 | 
                
                  233
                 | 
                
                  +$rows = $result->fetch_all_hash;
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  234
                 | 
                
                  +is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag1 with table dot");
                 | 
              
              
              
                | 
                  
                 | 
                
                  235
                 | 
                
                  +
 
                 | 
              
              
              
                | 
                  219
                 | 
                
                  236
                 | 
                
                   $tmpl = "select * from table1 where {<= key1} and {like key2};";
                 | 
              
              
              
                | 
                  220
                 | 
                
                  237
                 | 
                
                   $query = $dbi->create_query($tmpl);
 
                 | 
              
              
              
                | 
                  221
                 | 
                
                  238
                 | 
                
                   $result = $dbi->execute($query, {key1 => 1, key2 => '%2%'});
                 | 
              
              
              
                | 
                  222
                 | 
                
                  239
                 | 
                
                   $rows = $result->fetch_all_hash;
 
                 | 
              
              
              
                | 
                  223
                 | 
                
                  240
                 | 
                
                   is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag2");
                 | 
              
              
              
                | 
                  224
                 | 
                
                  241
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  242
                 | 
                
                  +$tmpl = "select * from table1 where {<= table1.key1} and {like table1.key2};";
                 | 
              
              
              
                | 
                  
                 | 
                
                  243
                 | 
                
                  +$query = $dbi->create_query($tmpl);
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  244
                 | 
                
                  +$result = $dbi->execute($query, {table1 => {key1 => 1, key2 => '%2%'}});
                 | 
              
              
              
                | 
                  
                 | 
                
                  245
                 | 
                
                  +$rows = $result->fetch_all_hash;
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  246
                 | 
                
                  +is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag2 with table");
                 | 
              
              
              
                | 
                  
                 | 
                
                  247
                 | 
                
                  +
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  248
                 | 
                
                  +$tmpl = "select * from table1 where {<= table1.key1} and {like table1.key2};";
                 | 
              
              
              
                | 
                  
                 | 
                
                  249
                 | 
                
                  +$query = $dbi->create_query($tmpl);
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  250
                 | 
                
                  +$result = $dbi->execute($query, {'table1.key1' => 1, 'table1.key2' => '%2%'});
                 | 
              
              
              
                | 
                  
                 | 
                
                  251
                 | 
                
                  +$rows = $result->fetch_all_hash;
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  252
                 | 
                
                  +is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag2 with table dot");
                 | 
              
              
              
                | 
                  
                 | 
                
                  253
                 | 
                
                  +
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  254
                 | 
                
                  +
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  255
                 | 
                
                  +
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  256
                 | 
                
                  +test 'DIB::Custom::SQL::Template';
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  257
                 | 
                
                  +
 
                 | 
              
              
              
                | 
                  225
                 | 
                
                  258
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  226
                 | 
                
                  259
                 | 
                
                   test 'DBI::Custom::SQL::Template insert tag';
 
                 | 
              
              
              
                | 
                  227
                 | 
                
                  260
                 | 
                
                   $dbi->do("delete from table1");
                 | 
              
              
              
                | 
                  ...
                 | 
                
                  ...
                 | 
                
                  @@ -242,11 +275,16 @@ is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$te
                 | 
              
              
              
                | 
                  242
                 | 
                
                  275
                 | 
                
                   $dbi->do("delete from table1");
                 | 
              
              
              
                | 
                  243
                 | 
                
                  276
                 | 
                
                   $insert_tmpl = 'insert into table1 {insert table1.key1 table1.key2 table1.key3 table1.key4 table1.key5}';
                 | 
              
              
              
                | 
                  244
                 | 
                
                  277
                 | 
                
                   $dbi->execute($insert_tmpl, {table1 => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}});
                 | 
              
              
              
                | 
                  245
                 | 
                
                  
                 | 
                
                  -
 
                 | 
              
              
              
                | 
                  246
                 | 
                
                  278
                 | 
                
                   $result = $dbi->execute($SELECT_TMPL->{0});
                 | 
              
              
              
                | 
                  247
                 | 
                
                  279
                 | 
                
                   $rows = $result->fetch_all_hash;
 
                 | 
              
              
              
                | 
                  248
                 | 
                
                  280
                 | 
                
                   is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : with table name");
                 | 
              
              
              
                | 
                  249
                 | 
                
                  281
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  282
                 | 
                
                  +$dbi->do("delete from table1");
                 | 
              
              
              
                | 
                  
                 | 
                
                  283
                 | 
                
                  +$insert_tmpl = 'insert into table1 {insert table1.key1 table1.key2 table1.key3 table1.key4 table1.key5}';
                 | 
              
              
              
                | 
                  
                 | 
                
                  284
                 | 
                
                  +$dbi->execute($insert_tmpl, {'table1.key1' => 1, 'table1.key2' => 2, 'table1.key3' => 3, 'table1.key4' => 4, 'table1.key5' => 5});
                 | 
              
              
              
                | 
                  
                 | 
                
                  285
                 | 
                
                  +$result = $dbi->execute($SELECT_TMPL->{0});
                 | 
              
              
              
                | 
                  
                 | 
                
                  286
                 | 
                
                  +$rows = $result->fetch_all_hash;
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  287
                 | 
                
                  +is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : with table name dot");
                 | 
              
              
              
                | 
                  250
                 | 
                
                  288
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  251
                 | 
                
                  289
                 | 
                
                   $dbi->do("delete from table1");
                 | 
              
              
              
                | 
                  252
                 | 
                
                  290
                 | 
                
                   $dbi->execute($insert_tmpl, {'#insert' => {table1 => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}}});
                 | 
              
              
              
                | 
                  ...
                 | 
                
                  ...
                 | 
                
                  @@ -254,6 +292,12 @@ $result = $dbi->execute($SELECT_TMPL->{0});
                 | 
              
              
              
                | 
                  254
                 | 
                
                  292
                 | 
                
                   $rows = $result->fetch_all_hash;
 
                 | 
              
              
              
                | 
                  255
                 | 
                
                  293
                 | 
                
                   is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : #insert with table name");
                 | 
              
              
              
                | 
                  256
                 | 
                
                  294
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  295
                 | 
                
                  +$dbi->do("delete from table1");
                 | 
              
              
              
                | 
                  
                 | 
                
                  296
                 | 
                
                  +$dbi->execute($insert_tmpl, {'#insert' => {'table1.key1' => 1, 'table1.key2' => 2, 'table1.key3' => 3, 'table1.key4' => 4, 'table1.key5' => 5}});
                 | 
              
              
              
                | 
                  
                 | 
                
                  297
                 | 
                
                  +$result = $dbi->execute($SELECT_TMPL->{0});
                 | 
              
              
              
                | 
                  
                 | 
                
                  298
                 | 
                
                  +$rows = $result->fetch_all_hash;
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  299
                 | 
                
                  +is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : #insert with table name dot");
                 | 
              
              
              
                | 
                  
                 | 
                
                  300
                 | 
                
                  +
 
                 | 
              
              
              
                | 
                  257
                 | 
                
                  301
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  258
                 | 
                
                  302
                 | 
                
                   test 'DBI::Custom::SQL::Template update tag';
 
                 | 
              
              
              
                | 
                  259
                 | 
                
                  303
                 | 
                
                   $dbi->do("delete from table1");
                 | 
              
              
              
                | 
                  ...
                 | 
                
                  ...
                 | 
                
                  @@ -282,18 +326,24 @@ $rows = $result->fetch_all_hash; 
                 | 
              
              
              
                | 
                  282
                 | 
                
                  326
                 | 
                
                   is_deeply($rows, [{key1 => 3, key2 => 3, key3 => 3, key4 => 3, key5 => 5},
                 | 
              
              
              
                | 
                  283
                 | 
                
                  327
                 | 
                
                                     {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : with table name");
                 | 
              
              
              
                | 
                  284
                 | 
                
                  328
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  285
                 | 
                
                  
                 | 
                
                  -$dbi->execute($update_tmpl, {'#update' => {table1 => {key1 => 4, key2 => 4, key3 => 4, key4 => 4}}, table1 => {key5 => 5}});
                 | 
              
              
              
                | 
                  
                 | 
                
                  329
                 | 
                
                  +$update_tmpl = 'update table1 {update table1.key1 table1.key2 table1.key3 table1.key4} where {= table1.key5}';
                 | 
              
              
              
                | 
                  
                 | 
                
                  330
                 | 
                
                  +$dbi->execute($update_tmpl, {'table1.key1' => 4, 'table1.key2' => 4, 'table1.key3' => 4, 'table1.key4' => 4, 'table1.key5' => 5});
                 | 
              
              
              
                | 
                  286
                 | 
                
                  331
                 | 
                
                   $result = $dbi->execute($SELECT_TMPL->{0});
                 | 
              
              
              
                | 
                  287
                 | 
                
                  332
                 | 
                
                   $rows = $result->fetch_all_hash;
 
                 | 
              
              
              
                | 
                  288
                 | 
                
                  333
                 | 
                
                   is_deeply($rows, [{key1 => 4, key2 => 4, key3 => 4, key4 => 4, key5 => 5},
                 | 
              
              
              
                | 
                  289
                 | 
                
                  
                 | 
                
                  -                  {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test update tag #update with table name");
                 | 
              
              
              
                | 
                  290
                 | 
                
                  
                 | 
                
                  -
 
                 | 
              
              
              
                | 
                  291
                 | 
                
                  
                 | 
                
                  -
 
                 | 
              
              
              
                | 
                  292
                 | 
                
                  
                 | 
                
                  -__END__
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  334
                 | 
                
                  +                  {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : with table name dot");
                 | 
              
              
              
                | 
                  293
                 | 
                
                  335
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  336
                 | 
                
                  +$dbi->execute($update_tmpl, {'#update' => {table1 => {key1 => 5, key2 => 5, key3 => 5, key4 => 5}}, table1 => {key5 => 5}});
                 | 
              
              
              
                | 
                  
                 | 
                
                  337
                 | 
                
                  +$result = $dbi->execute($SELECT_TMPL->{0});
                 | 
              
              
              
                | 
                  
                 | 
                
                  338
                 | 
                
                  +$rows = $result->fetch_all_hash;
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  339
                 | 
                
                  +is_deeply($rows, [{key1 => 5, key2 => 5, key3 => 5, key4 => 5, key5 => 5},
                 | 
              
              
              
                | 
                  
                 | 
                
                  340
                 | 
                
                  +                  {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test update tag #update with table name");
                 | 
              
              
              
                | 
                  294
                 | 
                
                  341
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  342
                 | 
                
                  +$dbi->execute($update_tmpl, {'#update' => {'table1.key1' => 6, 'table1.key2' => 6, 'table1.key3' => 6, 'table1.key4' => 6}, 'table1.key5' => 5});
                 | 
              
              
              
                | 
                  
                 | 
                
                  343
                 | 
                
                  +$result = $dbi->execute($SELECT_TMPL->{0});
                 | 
              
              
              
                | 
                  
                 | 
                
                  344
                 | 
                
                  +$rows = $result->fetch_all_hash;
 
                 | 
              
              
              
                | 
                  
                 | 
                
                  345
                 | 
                
                  +is_deeply($rows, [{key1 => 6, key2 => 6, key3 => 6, key4 => 6, key5 => 5},
                 | 
              
              
              
                | 
                  
                 | 
                
                  346
                 | 
                
                  +                  {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test update tag #update with table name dot");
                 | 
              
              
              
                | 
                  295
                 | 
                
                  347
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  296
                 | 
                
                  
                 | 
                
                  -$dbi->disconnnect;
 
                 | 
              
              
              
                | 
                  297
                 | 
                
                  348
                 | 
                
                   
 
                 | 
              
              
              
                | 
                  298
                 | 
                
                  
                 | 
                
                  -# Tag 'in' is easy to wrong
 
                 | 
              
              
              
                | 
                  299
                 | 
                
                  349
                 | 
                
                   
 
                 |