Showing 2 changed files with 25 additions and 2 deletions
+1 -1
lib/DBI/Custom.pm
... ...
@@ -301,7 +301,7 @@ sub _build_bind_values {
301 301
                     $found = 1;
302 302
                 }
303 303
                 
304
-                if ($key eq 'ARRAY') {
304
+                if (ref $key eq 'ARRAY') {
305 305
                     $root_params = $root_params->[$key->[0]];
306 306
                 }
307 307
                 else {
+24 -1
t/02-sqlite.t
... ...
@@ -208,6 +208,7 @@ $result       = $dbi->execute($select_query);
208 208
 $rows = $result->fetch_all_hash;
209 209
 is_deeply($rows, [{key1 => 3, key2 => 2}], "$test : insert with table name");
210 210
 
211
+
211 212
 test 'DBI::Custom::SQL::Template basic tag';
212 213
 $dbi->reconnect;
213 214
 $dbi->do($CREATE_TABLE->{1});
... ...
@@ -252,8 +253,30 @@ $rows = $result->fetch_all_hash;
252 253
 is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag2 with table dot");
253 254
 
254 255
 
256
+test 'DIB::Custom::SQL::Template in tag';
257
+$dbi->reconnect;
258
+$dbi->do($CREATE_TABLE->{1});
259
+$sth = $dbi->prepare("insert into table1 (key1, key2, key3, key4, key5) values (?, ?, ?, ?, ?);");
260
+$sth->execute(1, 2, 3, 4, 5);
261
+$sth->execute(6, 7, 8, 9, 10);
255 262
 
256
-test 'DIB::Custom::SQL::Template';
263
+$tmpl = "select * from table1 where {in key1 2};";
264
+$query = $dbi->create_query($tmpl);
265
+$result = $dbi->execute($query, {key1 => [9, 1]});
266
+$rows = $result->fetch_all_hash;
267
+is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic");
268
+
269
+$tmpl = "select * from table1 where {in table1.key1 2};";
270
+$query = $dbi->create_query($tmpl);
271
+$result = $dbi->execute($query, {table1 => {key1 => [9, 1]}});
272
+$rows = $result->fetch_all_hash;
273
+is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : with table");
274
+
275
+$tmpl = "select * from table1 where {in table1.key1 2};";
276
+$query = $dbi->create_query($tmpl);
277
+$result = $dbi->execute($query, {'table1.key1' => [9, 1]});
278
+$rows = $result->fetch_all_hash;
279
+is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : with table dot");
257 280
 
258 281
 
259 282
 test 'DBI::Custom::SQL::Template insert tag';