Showing 2 changed files with 164 additions and 101 deletions
+62
t/common.t
... ...
@@ -245,5 +245,67 @@ ok($@, "connect error");
245 245
 eval{$dbi->execute("{p }", {}, query => 1)};
246 246
 ok($@, "create_query invalid SQL template");
247 247
 
248
+test 'insert';
249
+$dbi->delete_all(table => 'table1');
250
+$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
251
+$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
252
+$result = $dbi->execute('select * from table1;');
253
+$rows   = $result->all;
254
+is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
255
+
256
+$dbi->execute('delete from table1');
257
+$dbi->register_filter(
258
+    twice       => sub { $_[0] * 2 },
259
+    three_times => sub { $_[0] * 3 }
260
+);
261
+$dbi->default_bind_filter('twice');
262
+$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, filter => {key1 => 'three_times'});
263
+$result = $dbi->execute('select * from table1;');
264
+$rows   = $result->all;
265
+is_deeply($rows, [{key1 => 3, key2 => 4}], "filter");
266
+$dbi->default_bind_filter(undef);
267
+
268
+$dbi->delete_all(table => 'table1');
269
+$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, append => '   ');
270
+$rows = $dbi->select(table => 'table1')->all;
271
+is_deeply($rows, [{key1 => 1, key2 => 2}], 'insert append');
272
+
273
+eval{$dbi->insert(table => 'table1', noexist => 1)};
274
+like($@, qr/noexist/, "invalid");
275
+
276
+eval{$dbi->insert(table => 'table', param => {';' => 1})};
277
+like($@, qr/safety/);
278
+
279
+__END__
280
+
281
+$dbi->quote('"');
282
+$dbi->execute('create table "table" ("select")');
283
+$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
284
+$dbi->insert(table => 'table', param => {select => 1});
285
+$result = $dbi->execute('select * from "table"');
286
+$rows   = $result->all;
287
+is_deeply($rows, [{select => 2}], "reserved word");
288
+
289
+$dbi->execute($create_table1);
290
+$dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
291
+$dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
292
+$result = $dbi->execute('select * from table1;');
293
+$rows   = $result->all;
294
+is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
295
+
296
+$dbi->execute("create table table1 (key1 char(255), key2 char(255), primary key(key1))");
297
+$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
298
+$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 4}, prefix => 'or replace');
299
+$result = $dbi->execute('select * from table1;');
300
+$rows   = $result->all;
301
+is_deeply($rows, [{key1 => 1, key2 => 4}], "basic");
302
+
303
+$dbi->execute($create_table1);
304
+$dbi->insert(table => 'table1', param => {key1 => \"'1'", key2 => 2});
305
+$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
306
+$result = $dbi->execute('select * from table1;');
307
+$rows   = $result->all;
308
+is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
309
+
248 310
 
249 311
 1;
+102 -101
t/sqlite.t
... ...
@@ -21,7 +21,8 @@ sub test { print "# $_[0]\n" }
21 21
 
22 22
 # Constant
23 23
 my %memory = (dsn => 'dbi:SQLite:dbname=:memory:');
24
-my $create_table_default = 'create table table1 (key1 char(255), key2 char(255));';
24
+my $create_table1 = 'create table table1 (key1 char(255), key2 char(255));';
25
+my $create_table1_2 = 'create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));';
25 26
 
26 27
 # Variables
27 28
 my $builder;
... ...
@@ -60,7 +61,7 @@ $dbi = DBIx::Custom->connect(%memory);
60 61
 
61 62
 test 'insert';
62 63
 $dbi = DBIx::Custom->connect(%memory);
63
-$dbi->execute($create_table_default);
64
+$dbi->execute($create_table1);
64 65
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
65 66
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
66 67
 $result = $dbi->execute('select * from table1;');
... ...
@@ -80,7 +81,7 @@ is_deeply($rows, [{key1 => 3, key2 => 4}], "filter");
80 81
 $dbi->default_bind_filter(undef);
81 82
 
82 83
 $dbi->execute('drop table table1');
83
-$dbi->execute($create_table_default);
84
+$dbi->execute($create_table1);
84 85
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, append => '   ');
85 86
 $rows = $dbi->select(table => 'table1')->all;
86 87
 is_deeply($rows, [{key1 => 1, key2 => 2}], 'insert append');
... ...
@@ -101,7 +102,7 @@ $rows   = $result->all;
101 102
 is_deeply($rows, [{select => 2}], "reserved word");
102 103
 
103 104
 $dbi = DBIx::Custom->connect(%memory);
104
-$dbi->execute($create_table_default);
105
+$dbi->execute($create_table1);
105 106
 $dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
106 107
 $dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
107 108
 $result = $dbi->execute('select * from table1;');
... ...
@@ -117,7 +118,7 @@ $rows   = $result->all;
117 118
 is_deeply($rows, [{key1 => 1, key2 => 4}], "basic");
118 119
 
119 120
 $dbi = DBIx::Custom->connect(%memory);
120
-$dbi->execute($create_table_default);
121
+$dbi->execute($create_table1);
121 122
 $dbi->insert(table => 'table1', param => {key1 => \"'1'", key2 => 2});
122 123
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
123 124
 $result = $dbi->execute('select * from table1;');
... ...
@@ -126,7 +127,7 @@ is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
126 127
 
127 128
 test 'update';
128 129
 $dbi = DBIx::Custom->connect(%memory);
129
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
130
+$dbi->execute($create_table1_2);
130 131
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
131 132
 $dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
132 133
 $dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1});
... ...
@@ -174,7 +175,7 @@ eval{$dbi->update(table => 'table1')};
174 175
 like($@, qr/where/, "not contain where");
175 176
 
176 177
 $dbi = DBIx::Custom->connect(%memory);
177
-$dbi->execute($create_table_default);
178
+$dbi->execute($create_table1);
178 179
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
179 180
 $where = $dbi->where;
180 181
 $where->clause(['and', 'key1 = :key1', 'key2 = :key2']);
... ...
@@ -184,7 +185,7 @@ $result = $dbi->select(table => 'table1');
184 185
 is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where');
185 186
 
186 187
 $dbi = DBIx::Custom->connect(%memory);
187
-$dbi->execute($create_table_default);
188
+$dbi->execute($create_table1);
188 189
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
189 190
 $dbi->update(
190 191
     table => 'table1',
... ...
@@ -198,7 +199,7 @@ $result = $dbi->select(table => 'table1');
198 199
 is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where');
199 200
 
200 201
 $dbi = DBIx::Custom->connect(%memory);
201
-$dbi->execute($create_table_default);
202
+$dbi->execute($create_table1);
202 203
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
203 204
 $where = $dbi->where;
204 205
 $where->clause(['and', 'key2 = :key2']);
... ...
@@ -239,7 +240,7 @@ $rows   = $result->all;
239 240
 is_deeply($rows, [{select => 2, update => 6}], "reserved word");
240 241
 
241 242
 $dbi = DBIx::Custom->connect(%memory);
242
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
243
+$dbi->execute($create_table1_2);
243 244
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
244 245
 $dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
245 246
 $dbi->update({key2 => 11}, table => 'table1', where => {key1 => 1});
... ...
@@ -259,7 +260,7 @@ $rows   = $result->all;
259 260
 is_deeply($rows, [{key1 => 1, key2 => 4}], "basic");
260 261
 
261 262
 $dbi = DBIx::Custom->connect(%memory);
262
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
263
+$dbi->execute($create_table1_2);
263 264
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
264 265
 $dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
265 266
 $dbi->update(table => 'table1', param => {key2 => \"'11'"}, where => {key1 => 1});
... ...
@@ -271,7 +272,7 @@ is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
271 272
 
272 273
 test 'update_all';
273 274
 $dbi = DBIx::Custom->connect(%memory);
274
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
275
+$dbi->execute($create_table1_2);
275 276
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
276 277
 $dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
277 278
 $dbi->register_filter(twice => sub { $_[0] * 2 });
... ...
@@ -285,7 +286,7 @@ is_deeply($rows, [{key1 => 1, key2 => 20, key3 => 3, key4 => 4, key5 => 5},
285 286
 
286 287
 test 'delete';
287 288
 $dbi = DBIx::Custom->connect(%memory);
288
-$dbi->execute($create_table_default);
289
+$dbi->execute($create_table1);
289 290
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
290 291
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
291 292
 $dbi->delete(table => 'table1', where => {key1 => 1});
... ...
@@ -315,7 +316,7 @@ eval{$dbi->delete(table => 'table1', where => {key1 => 1}, noexist => 1)};
315 316
 like($@, qr/noexist/, "invalid");
316 317
 
317 318
 $dbi = DBIx::Custom->connect(%memory);
318
-$dbi->execute($create_table_default);
319
+$dbi->execute($create_table1);
319 320
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
320 321
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
321 322
 $where = $dbi->where;
... ...
@@ -326,7 +327,7 @@ $result = $dbi->select(table => 'table1');
326 327
 is_deeply($result->all, [{key1 => 3, key2 => 4}], 'delete() where');
327 328
 
328 329
 $dbi = DBIx::Custom->connect(%memory);
329
-$dbi->execute($create_table_default);
330
+$dbi->execute($create_table1);
330 331
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
331 332
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
332 333
 $dbi->delete(
... ...
@@ -349,7 +350,7 @@ is_deeply($rows, [], "basic");
349 350
 
350 351
 test 'delete error';
351 352
 $dbi = DBIx::Custom->connect(%memory);
352
-$dbi->execute($create_table_default);
353
+$dbi->execute($create_table1);
353 354
 eval{$dbi->delete(table => 'table1')};
354 355
 like($@, qr/"where" must be specified/,
355 356
          "where key-value pairs not specified");
... ...
@@ -369,7 +370,7 @@ is_deeply($rows, [], "reserved word");
369 370
 
370 371
 test 'delete_all';
371 372
 $dbi = DBIx::Custom->connect(%memory);
372
-$dbi->execute($create_table_default);
373
+$dbi->execute($create_table1);
373 374
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
374 375
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
375 376
 $dbi->delete_all(table => 'table1');
... ...
@@ -380,7 +381,7 @@ is_deeply($rows, [], "basic");
380 381
 
381 382
 test 'select';
382 383
 $dbi = DBIx::Custom->connect(%memory);
383
-$dbi->execute($create_table_default);
384
+$dbi->execute($create_table1);
384 385
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
385 386
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
386 387
 $rows = $dbi->select(table => 'table1')->all;
... ...
@@ -440,7 +441,7 @@ $dbi->register_filter(
440 441
     three_times => sub { $_[0] * 3 }
441 442
 );
442 443
 $dbi->default_fetch_filter('twice');
443
-$dbi->execute($create_table_default);
444
+$dbi->execute($create_table1);
444 445
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
445 446
 $result = $dbi->select(table => 'table1');
446 447
 $result->filter({key1 => 'three_times'});
... ...
@@ -458,7 +459,7 @@ is($dbi->filters->{encode_utf8}->('あ'),
458 459
 
459 460
 test 'transaction';
460 461
 $dbi = DBIx::Custom->connect(%memory);
461
-$dbi->execute($create_table_default);
462
+$dbi->execute($create_table1);
462 463
 $dbi->dbh->begin_work;
463 464
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
464 465
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
... ...
@@ -468,7 +469,7 @@ is_deeply(scalar $result->all, [{key1 => 1, key2 => 2}, {key1 => 2, key2 => 3}],
468 469
           "commit");
469 470
 
470 471
 $dbi = DBIx::Custom->connect(%memory);
471
-$dbi->execute($create_table_default);
472
+$dbi->execute($create_table1);
472 473
 $dbi->dbh->begin_work(0);
473 474
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
474 475
 $dbi->dbh->rollback;
... ...
@@ -479,14 +480,14 @@ ok(! $result->fetch_first, "rollback");
479 480
 test 'cache';
480 481
 $dbi = DBIx::Custom->connect(%memory);
481 482
 $dbi->cache(1);
482
-$dbi->execute($create_table_default);
483
+$dbi->execute($create_table1);
483 484
 $source = 'select * from table1 where key1 = :key1 and key2 = :key2;';
484 485
 $dbi->execute($source, {}, query => 1);
485 486
 is_deeply($dbi->{_cached}->{$source}, 
486 487
           {sql => "select * from table1 where key1 = ? and key2 = ?;", columns => ['key1', 'key2'], tables => []}, "cache");
487 488
 
488 489
 $dbi = DBIx::Custom->connect(%memory);
489
-$dbi->execute($create_table_default);
490
+$dbi->execute($create_table1);
490 491
 $dbi->{_cached} = {};
491 492
 $dbi->cache(0);
492 493
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
... ...
@@ -494,7 +495,7 @@ is(scalar keys %{$dbi->{_cached}}, 0, 'not cache');
494 495
 
495 496
 test 'execute';
496 497
 $dbi = DBIx::Custom->connect(%memory);
497
-$dbi->execute($create_table_default);
498
+$dbi->execute($create_table1);
498 499
 {
499 500
     local $Carp::Verbose = 0;
500 501
     eval{$dbi->execute('select * frm table1')};
... ...
@@ -529,7 +530,7 @@ ok($@, "execute fail");
529 530
 
530 531
 test 'transaction';
531 532
 $dbi = DBIx::Custom->connect(%memory);
532
-$dbi->execute($create_table_default);
533
+$dbi->execute($create_table1);
533 534
 
534 535
 $dbi->begin_work;
535 536
 
... ...
@@ -588,7 +589,7 @@ ok($@, "not exists");
588 589
 
589 590
 test 'out filter';
590 591
 $dbi = DBIx::Custom->connect(%memory);
591
-$dbi->execute($create_table_default);
592
+$dbi->execute($create_table1);
592 593
 $dbi->register_filter(twice => sub { $_[0] * 2 });
593 594
 $dbi->register_filter(three_times => sub { $_[0] * 3});
594 595
 $dbi->apply_filter(
... ...
@@ -603,7 +604,7 @@ $row   = $result->one;
603 604
 is_deeply($row, {key1 => 6, key2 => 12}, "insert");
604 605
 
605 606
 $dbi = DBIx::Custom->connect(%memory);
606
-$dbi->execute($create_table_default);
607
+$dbi->execute($create_table1);
607 608
 $dbi->register_filter(twice => sub { $_[0] * 2 });
608 609
 $dbi->register_filter(three_times => sub { $_[0] * 3});
609 610
 $dbi->apply_filter(
... ...
@@ -618,7 +619,7 @@ $row   = $result->one;
618 619
 is_deeply($row, {key1 => 1, key2 => 6}, "insert");
619 620
 
620 621
 $dbi = DBIx::Custom->connect(%memory);
621
-$dbi->execute($create_table_default);
622
+$dbi->execute($create_table1);
622 623
 $dbi->register_filter(twice => sub { $_[0] * 2 });
623 624
 $dbi->apply_filter(
624 625
     'table1', 'key1' => {out => 'twice', in => 'twice'}
... ...
@@ -630,7 +631,7 @@ $row   = $result->one;
630 631
 is_deeply($row, {key1 => 4, key2 => 2}, "update");
631 632
 
632 633
 $dbi = DBIx::Custom->connect(%memory);
633
-$dbi->execute($create_table_default);
634
+$dbi->execute($create_table1);
634 635
 $dbi->register_filter(twice => sub { $_[0] * 2 });
635 636
 $dbi->apply_filter(
636 637
     'table1', 'key1' => {out => 'twice', in => 'twice'}
... ...
@@ -642,7 +643,7 @@ $rows   = $result->all;
642 643
 is_deeply($rows, [], "delete");
643 644
 
644 645
 $dbi = DBIx::Custom->connect(%memory);
645
-$dbi->execute($create_table_default);
646
+$dbi->execute($create_table1);
646 647
 $dbi->register_filter(twice => sub { $_[0] * 2 });
647 648
 $dbi->apply_filter(
648 649
     'table1', 'key1' => {out => 'twice', in => 'twice'}
... ...
@@ -654,7 +655,7 @@ $rows   = $result->all;
654 655
 is_deeply($rows, [{key1 => 4, key2 => 4}], "select");
655 656
 
656 657
 $dbi = DBIx::Custom->connect(%memory);
657
-$dbi->execute($create_table_default);
658
+$dbi->execute($create_table1);
658 659
 $dbi->register_filter(twice => sub { $_[0] * 2 });
659 660
 $dbi->apply_filter(
660 661
     'table1', 'key1' => {out => 'twice', in => 'twice'}
... ...
@@ -667,7 +668,7 @@ $rows   = $result->all;
667 668
 is_deeply($rows, [{key1 => 4, key2 => 2}], "execute");
668 669
 
669 670
 $dbi = DBIx::Custom->connect(%memory);
670
-$dbi->execute($create_table_default);
671
+$dbi->execute($create_table1);
671 672
 $dbi->register_filter(twice => sub { $_[0] * 2 });
672 673
 $dbi->apply_filter(
673 674
     'table1', 'key1' => {out => 'twice', in => 'twice'}
... ...
@@ -679,7 +680,7 @@ $rows   = $result->all;
679 680
 is_deeply($rows, [{key1 => 4, key2 => 2}], "execute table tag");
680 681
 
681 682
 $dbi = DBIx::Custom->connect(%memory);
682
-$dbi->execute($create_table_default);
683
+$dbi->execute($create_table1);
683 684
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
684 685
 $dbi->register_filter(twice => sub { $_[0] * 2 });
685 686
 $dbi->register_filter(three_times => sub { $_[0] * 3 });
... ...
@@ -757,7 +758,7 @@ is_deeply($infos,
757 758
 
758 759
 test 'limit';
759 760
 $dbi = DBIx::Custom->connect(%memory);
760
-$dbi->execute($create_table_default);
761
+$dbi->execute($create_table1);
761 762
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
762 763
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 4});
763 764
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 6});
... ...
@@ -810,13 +811,13 @@ test 'connect super';
810 811
 }
811 812
 
812 813
 $dbi = MyDBI->connect(%memory);
813
-$dbi->execute($create_table_default);
814
+$dbi->execute($create_table1);
814 815
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
815 816
 is($dbi->select(table => 'table1')->one->{key1}, 1);
816 817
 
817 818
 $dbi = MyDBI->new(%memory);
818 819
 $dbi->connect;
819
-$dbi->execute($create_table_default);
820
+$dbi->execute($create_table1);
820 821
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
821 822
 is($dbi->select(table => 'table1')->one->{key1}, 1);
822 823
 
... ...
@@ -833,13 +834,13 @@ is($dbi->select(table => 'table1')->one->{key1}, 1);
833 834
 }
834 835
 
835 836
 $dbi = MyDBI->connect(%memory);
836
-$dbi->execute($create_table_default);
837
+$dbi->execute($create_table1);
837 838
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
838 839
 is($dbi->select(table => 'table1')->one->{key1}, 1);
839 840
 
840 841
 test 'end_filter';
841 842
 $dbi = DBIx::Custom->connect(%memory);
842
-$dbi->execute($create_table_default);
843
+$dbi->execute($create_table1);
843 844
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
844 845
 $result = $dbi->select(table => 'table1');
845 846
 $result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 });
... ...
@@ -848,7 +849,7 @@ $row = $result->fetch_first;
848 849
 is_deeply($row, [6, 40]);
849 850
 
850 851
 $dbi = DBIx::Custom->connect(%memory);
851
-$dbi->execute($create_table_default);
852
+$dbi->execute($create_table1);
852 853
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
853 854
 $result = $dbi->select(table => 'table1');
854 855
 $result->filter([qw/key1 key2/] => sub { $_[0] * 2 });
... ...
@@ -857,7 +858,7 @@ $row = $result->fetch_first;
857 858
 is_deeply($row, [6, 12]);
858 859
 
859 860
 $dbi = DBIx::Custom->connect(%memory);
860
-$dbi->execute($create_table_default);
861
+$dbi->execute($create_table1);
861 862
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
862 863
 $result = $dbi->select(table => 'table1');
863 864
 $result->filter([[qw/key1 key2/] => sub { $_[0] * 2 }]);
... ...
@@ -896,7 +897,7 @@ is_deeply($row, {key1 => 1, key2 => 40}, 'apply_filter overwrite');
896 897
 
897 898
 test 'remove_end_filter and remove_filter';
898 899
 $dbi = DBIx::Custom->connect(%memory);
899
-$dbi->execute($create_table_default);
900
+$dbi->execute($create_table1);
900 901
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
901 902
 $result = $dbi->select(table => 'table1');
902 903
 $row = $result
... ...
@@ -909,7 +910,7 @@ is_deeply($row, [1, 2]);
909 910
 
910 911
 test 'empty where select';
911 912
 $dbi = DBIx::Custom->connect(%memory);
912
-$dbi->execute($create_table_default);
913
+$dbi->execute($create_table1);
913 914
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
914 915
 $result = $dbi->select(table => 'table1', where => {});
915 916
 $row = $result->one;
... ...
@@ -917,7 +918,7 @@ is_deeply($row, {key1 => 1, key2 => 2});
917 918
 
918 919
 test 'select query option';
919 920
 $dbi = DBIx::Custom->connect(%memory);
920
-$dbi->execute($create_table_default);
921
+$dbi->execute($create_table1);
921 922
 $query = $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, query => 1);
922 923
 is(ref $query, 'DBIx::Custom::Query');
923 924
 $query = $dbi->update(table => 'table1', where => {key1 => 1}, param => {key2 => 2}, query => 1);
... ...
@@ -929,7 +930,7 @@ is(ref $query, 'DBIx::Custom::Query');
929 930
 
930 931
 test 'where';
931 932
 $dbi = DBIx::Custom->connect(%memory);
932
-$dbi->execute($create_table_default);
933
+$dbi->execute($create_table1);
933 934
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
934 935
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
935 936
 $where = $dbi->where->clause(['and', 'key1 = :key1', 'key2 = :key2']);
... ...
@@ -1403,7 +1404,7 @@ $dbi->apply_filter(
1403 1404
 
1404 1405
 );
1405 1406
 $dbi = DBIx::Custom->connect(%memory);
1406
-$dbi->execute($create_table_default);
1407
+$dbi->execute($create_table1);
1407 1408
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1408 1409
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1409 1410
 $dbi->apply_filter('table1', 'key2', 
... ...
@@ -1412,7 +1413,7 @@ $rows = $dbi->select(table => 'table1', where => {key2 => 1})->all;
1412 1413
 is_deeply($rows, [{key1 => 1, key2 => 6}]);
1413 1414
 
1414 1415
 $dbi = DBIx::Custom->connect(%memory);
1415
-$dbi->execute($create_table_default);
1416
+$dbi->execute($create_table1);
1416 1417
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1417 1418
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1418 1419
 $dbi->apply_filter('table1', 'key2', {});
... ...
@@ -1431,7 +1432,7 @@ eval{DBIx::Custom->connect()};
1431 1432
 like($@, qr/_connect/);
1432 1433
 
1433 1434
 $dbi = DBIx::Custom->connect(%memory);
1434
-$dbi->execute($create_table_default);
1435
+$dbi->execute($create_table1);
1435 1436
 $dbi->register_filter(twice => sub { $_[0] * 2 });
1436 1437
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2},
1437 1438
              filter => {key1 => 'twice'});
... ...
@@ -1458,7 +1459,7 @@ eval {$dbi->execute('select * from table1 {} {= author') };
1458 1459
 like($@, qr/Tag not finished/);
1459 1460
 
1460 1461
 $dbi = DBIx::Custom->connect(%memory);
1461
-$dbi->execute($create_table_default);
1462
+$dbi->execute($create_table1);
1462 1463
 $dbi->register_filter(one => sub { 1 });
1463 1464
 $result = $dbi->select(table => 'table1');
1464 1465
 eval {$result->filter(key1 => 'no')};
... ...
@@ -1643,7 +1644,7 @@ is_deeply($dbi->model('company')->columns, ['id', 'name']);
1643 1644
 
1644 1645
 test 'delete_at';
1645 1646
 $dbi = DBIx::Custom->connect(%memory);
1646
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1647
+$dbi->execute($create_table1_2);
1647 1648
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1648 1649
 $dbi->delete_at(
1649 1650
     table => 'table1',
... ...
@@ -1662,7 +1663,7 @@ is_deeply($dbi->select(table => 'table1')->all, []);
1662 1663
 
1663 1664
 test 'insert_at';
1664 1665
 $dbi = DBIx::Custom->connect(%memory);
1665
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1666
+$dbi->execute($create_table1_2);
1666 1667
 $dbi->insert_at(
1667 1668
     primary_key => ['key1', 'key2'], 
1668 1669
     table => 'table1',
... ...
@@ -1697,7 +1698,7 @@ eval {
1697 1698
 like($@, qr/must be/);
1698 1699
 
1699 1700
 $dbi = DBIx::Custom->connect(%memory);
1700
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1701
+$dbi->execute($create_table1_2);
1701 1702
 $dbi->insert_at(
1702 1703
     {key3 => 3},
1703 1704
     primary_key => ['key1', 'key2'], 
... ...
@@ -1710,7 +1711,7 @@ is($dbi->select(table => 'table1')->one->{key3}, 3);
1710 1711
 
1711 1712
 test 'update_at';
1712 1713
 $dbi = DBIx::Custom->connect(%memory);
1713
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1714
+$dbi->execute($create_table1_2);
1714 1715
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1715 1716
 $dbi->update_at(
1716 1717
     table => 'table1',
... ...
@@ -1735,7 +1736,7 @@ is($dbi->select(table => 'table1')->one->{key2}, 2);
1735 1736
 is($dbi->select(table => 'table1')->one->{key3}, 4);
1736 1737
 
1737 1738
 $dbi = DBIx::Custom->connect(%memory);
1738
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1739
+$dbi->execute($create_table1_2);
1739 1740
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1740 1741
 $dbi->update_at(
1741 1742
     {key3 => 4},
... ...
@@ -1749,7 +1750,7 @@ is($dbi->select(table => 'table1')->one->{key3}, 4);
1749 1750
 
1750 1751
 test 'select_at';
1751 1752
 $dbi = DBIx::Custom->connect(%memory);
1752
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1753
+$dbi->execute($create_table1_2);
1753 1754
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1754 1755
 $result = $dbi->select_at(
1755 1756
     table => 'table1',
... ...
@@ -1843,7 +1844,7 @@ test 'model delete_at';
1843 1844
     }
1844 1845
 }
1845 1846
 $dbi = MyDBI6->connect(%memory);
1846
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1847
+$dbi->execute($create_table1_2);
1847 1848
 $dbi->execute("create table table2 (key1, key2, key3)");
1848 1849
 $dbi->execute("create table table3 (key1, key2, key3)");
1849 1850
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
... ...
@@ -1858,7 +1859,7 @@ is_deeply($dbi->select(table => 'table1')->all, []);
1858 1859
 
1859 1860
 test 'model insert_at';
1860 1861
 $dbi = MyDBI6->connect(%memory);
1861
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1862
+$dbi->execute($create_table1_2);
1862 1863
 $dbi->model('table1')->insert_at(
1863 1864
     where => [1, 2],
1864 1865
     param => {key3 => 3}
... ...
@@ -1871,7 +1872,7 @@ is($row->{key3}, 3);
1871 1872
 
1872 1873
 test 'model update_at';
1873 1874
 $dbi = MyDBI6->connect(%memory);
1874
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1875
+$dbi->execute($create_table1_2);
1875 1876
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1876 1877
 $dbi->model('table1')->update_at(
1877 1878
     where => [1, 2],
... ...
@@ -1885,7 +1886,7 @@ is($row->{key3}, 4);
1885 1886
 
1886 1887
 test 'model select_at';
1887 1888
 $dbi = MyDBI6->connect(%memory);
1888
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1889
+$dbi->execute($create_table1_2);
1889 1890
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1890 1891
 $result = $dbi->model('table1')->select_at(where => [1, 2]);
1891 1892
 $row = $result->one;
... ...
@@ -1910,7 +1911,7 @@ test 'mycolumn and column';
1910 1911
     }
1911 1912
 }
1912 1913
 $dbi = MyDBI7->connect(%memory);
1913
-$dbi->execute($create_table_default);
1914
+$dbi->execute($create_table1);
1914 1915
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
1915 1916
 $dbi->separator('__');
1916 1917
 $dbi->setup_model;
... ...
@@ -1926,7 +1927,7 @@ is_deeply($result->one,
1926 1927
 
1927 1928
 test 'update_param';
1928 1929
 $dbi = DBIx::Custom->connect(%memory);
1929
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1930
+$dbi->execute($create_table1_2);
1930 1931
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
1931 1932
 $dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
1932 1933
 
... ...
@@ -1945,7 +1946,7 @@ is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
1945 1946
 
1946 1947
 
1947 1948
 $dbi = DBIx::Custom->connect(%memory);
1948
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1949
+$dbi->execute($create_table1_2);
1949 1950
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
1950 1951
 $dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
1951 1952
 
... ...
@@ -1963,7 +1964,7 @@ is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 33, key4 => 4, key5 => 5},
1963 1964
                   "basic");
1964 1965
 
1965 1966
 $dbi = DBIx::Custom->connect(%memory);
1966
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1967
+$dbi->execute($create_table1_2);
1967 1968
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
1968 1969
 $dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
1969 1970
 
... ...
@@ -1987,7 +1988,7 @@ like($@, qr/not safety/);
1987 1988
 
1988 1989
 test 'update_param';
1989 1990
 $dbi = DBIx::Custom->connect(%memory);
1990
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
1991
+$dbi->execute($create_table1_2);
1991 1992
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
1992 1993
 $dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
1993 1994
 
... ...
@@ -2007,7 +2008,7 @@ is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
2007 2008
 
2008 2009
 test 'insert_param';
2009 2010
 $dbi = DBIx::Custom->connect(%memory);
2010
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
2011
+$dbi->execute($create_table1_2);
2011 2012
 $param = {key1 => 1, key2 => 2};
2012 2013
 $insert_param = $dbi->insert_param($param);
2013 2014
 $sql = <<"EOS";
... ...
@@ -2019,7 +2020,7 @@ is($dbi->select(table => 'table1')->one->{key2}, 2);
2019 2020
 
2020 2021
 $dbi = DBIx::Custom->connect(%memory);
2021 2022
 $dbi->quote('"');
2022
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
2023
+$dbi->execute($create_table1_2);
2023 2024
 $param = {key1 => 1, key2 => 2};
2024 2025
 $insert_param = $dbi->insert_param($param);
2025 2026
 $sql = <<"EOS";
... ...
@@ -2035,7 +2036,7 @@ like($@, qr/not safety/);
2035 2036
 
2036 2037
 test 'join';
2037 2038
 $dbi = DBIx::Custom->connect(%memory);
2038
-$dbi->execute($create_table_default);
2039
+$dbi->execute($create_table1);
2039 2040
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2040 2041
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
2041 2042
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
... ...
@@ -2095,7 +2096,7 @@ is_deeply($rows, [{table1__key1 => 1}]);
2095 2096
 
2096 2097
 $dbi = DBIx::Custom->connect(%memory);
2097 2098
 $dbi->quote('"');
2098
-$dbi->execute($create_table_default);
2099
+$dbi->execute($create_table1);
2099 2100
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2100 2101
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
2101 2102
 $dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5});
... ...
@@ -2123,7 +2124,7 @@ is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}],
2123 2124
 }
2124 2125
 
2125 2126
 $dbi = DBIx::Custom->connect(%memory);
2126
-$dbi->execute($create_table_default);
2127
+$dbi->execute($create_table1);
2127 2128
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2128 2129
 $sql = <<"EOS";
2129 2130
 left outer join (
... ...
@@ -2143,7 +2144,7 @@ $rows = $dbi->select(
2143 2144
 is_deeply($rows, [{latest_table1__key1 => 1}]);
2144 2145
 
2145 2146
 $dbi = DBIx::Custom->connect(%memory);
2146
-$dbi->execute($create_table_default);
2147
+$dbi->execute($create_table1);
2147 2148
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
2148 2149
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2149 2150
 $dbi->insert(table => 'table2', param => {key1 => 1, key3 => 4});
... ...
@@ -2173,7 +2174,7 @@ $result = $dbi->select(
2173 2174
 is_deeply($result->all, [{'table2.key3' => 4}]);
2174 2175
 
2175 2176
 $dbi = DBIx::Custom->connect(%memory);
2176
-$dbi->execute($create_table_default);
2177
+$dbi->execute($create_table1);
2177 2178
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
2178 2179
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2179 2180
 $dbi->insert(table => 'table2', param => {key1 => 1, key3 => 4});
... ...
@@ -2192,7 +2193,7 @@ is_deeply($result->all, [{'table2.key3' => 4}]);
2192 2193
 
2193 2194
 test 'mycolumn';
2194 2195
 $dbi = MyDBI8->connect(%memory);
2195
-$dbi->execute($create_table_default);
2196
+$dbi->execute($create_table1);
2196 2197
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
2197 2198
 $dbi->setup_model;
2198 2199
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
... ...
@@ -2257,14 +2258,14 @@ test 'dbi method from model';
2257 2258
     }
2258 2259
 }
2259 2260
 $dbi = MyDBI9->connect(%memory);
2260
-$dbi->execute($create_table_default);
2261
+$dbi->execute($create_table1);
2261 2262
 $model = $dbi->model('table1');
2262 2263
 eval{$model->execute('select * from table1')};
2263 2264
 ok(!$@);
2264 2265
 
2265 2266
 test 'column table option';
2266 2267
 $dbi = MyDBI9->connect(%memory);
2267
-$dbi->execute($create_table_default);
2268
+$dbi->execute($create_table1);
2268 2269
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
2269 2270
 $dbi->setup_model;
2270 2271
 $dbi->execute('insert into table1 (key1, key2) values (1, 2);');
... ...
@@ -2370,7 +2371,7 @@ is($row->{key1_length}, length $binary);
2370 2371
 
2371 2372
 test 'create_model';
2372 2373
 $dbi = DBIx::Custom->connect(%memory);
2373
-$dbi->execute($create_table_default);
2374
+$dbi->execute($create_table1);
2374 2375
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
2375 2376
 
2376 2377
 $dbi->create_model(
... ...
@@ -2431,7 +2432,7 @@ is_deeply($param, {key1 => [1, 2, 3, 4], key2 => [1, 2, 3], key3 => [1, 2, 3]});
2431 2432
 
2432 2433
 test 'select() param option';
2433 2434
 $dbi = DBIx::Custom->connect(%memory);
2434
-$dbi->execute($create_table_default);
2435
+$dbi->execute($create_table1);
2435 2436
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2436 2437
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2437 2438
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
... ...
@@ -2450,7 +2451,7 @@ is_deeply($rows, [{table1_key1 => 2, key2 => 3, key3 => 5}]);
2450 2451
 
2451 2452
 test 'select() wrap option';
2452 2453
 $dbi = DBIx::Custom->connect(%memory);
2453
-$dbi->execute($create_table_default);
2454
+$dbi->execute($create_table1);
2454 2455
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2455 2456
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2456 2457
 $rows = $dbi->select(
... ...
@@ -2471,7 +2472,7 @@ like($@, qr/array/);
2471 2472
 
2472 2473
 test 'select() string where';
2473 2474
 $dbi = DBIx::Custom->connect(%memory);
2474
-$dbi->execute($create_table_default);
2475
+$dbi->execute($create_table1);
2475 2476
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2476 2477
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2477 2478
 $rows = $dbi->select(
... ...
@@ -2482,7 +2483,7 @@ $rows = $dbi->select(
2482 2483
 is_deeply($rows, [{key1 => 1, key2 => 2}]);
2483 2484
 
2484 2485
 $dbi = DBIx::Custom->connect(%memory);
2485
-$dbi->execute($create_table_default);
2486
+$dbi->execute($create_table1);
2486 2487
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2487 2488
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2488 2489
 $rows = $dbi->select(
... ...
@@ -2496,7 +2497,7 @@ is_deeply($rows, [{key1 => 1, key2 => 2}]);
2496 2497
 
2497 2498
 test 'delete() string where';
2498 2499
 $dbi = DBIx::Custom->connect(%memory);
2499
-$dbi->execute($create_table_default);
2500
+$dbi->execute($create_table1);
2500 2501
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2501 2502
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2502 2503
 $dbi->delete(
... ...
@@ -2508,7 +2509,7 @@ $rows = $dbi->select(table => 'table1')->all;
2508 2509
 is_deeply($rows, [{key1 => 2, key2 => 3}]);
2509 2510
 
2510 2511
 $dbi = DBIx::Custom->connect(%memory);
2511
-$dbi->execute($create_table_default);
2512
+$dbi->execute($create_table1);
2512 2513
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2513 2514
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2514 2515
 $dbi->delete(
... ...
@@ -2524,7 +2525,7 @@ is_deeply($rows, [{key1 => 2, key2 => 3}]);
2524 2525
 
2525 2526
 test 'update() string where';
2526 2527
 $dbi = DBIx::Custom->connect(%memory);
2527
-$dbi->execute($create_table_default);
2528
+$dbi->execute($create_table1);
2528 2529
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2529 2530
 $dbi->update(
2530 2531
     table => 'table1',
... ...
@@ -2536,7 +2537,7 @@ $rows = $dbi->select(table => 'table1')->all;
2536 2537
 is_deeply($rows, [{key1 => 5, key2 => 2}]);
2537 2538
 
2538 2539
 $dbi = DBIx::Custom->connect(%memory);
2539
-$dbi->execute($create_table_default);
2540
+$dbi->execute($create_table1);
2540 2541
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2541 2542
 $dbi->update(
2542 2543
     table => 'table1',
... ...
@@ -2551,7 +2552,7 @@ is_deeply($rows, [{key1 => 5, key2 => 2}]);
2551 2552
 
2552 2553
 test 'insert id and primary_key option';
2553 2554
 $dbi = DBIx::Custom->connect(%memory);
2554
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
2555
+$dbi->execute($create_table1_2);
2555 2556
 $dbi->insert(
2556 2557
     primary_key => ['key1', 'key2'], 
2557 2558
     table => 'table1',
... ...
@@ -2575,7 +2576,7 @@ is($dbi->select(table => 'table1')->one->{key2}, 2);
2575 2576
 is($dbi->select(table => 'table1')->one->{key3}, 3);
2576 2577
 
2577 2578
 $dbi = DBIx::Custom->connect(%memory);
2578
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
2579
+$dbi->execute($create_table1_2);
2579 2580
 $dbi->insert(
2580 2581
     {key3 => 3},
2581 2582
     primary_key => ['key1', 'key2'], 
... ...
@@ -2589,7 +2590,7 @@ is($dbi->select(table => 'table1')->one->{key3}, 3);
2589 2590
 
2590 2591
 test 'model insert id and primary_key option';
2591 2592
 $dbi = MyDBI6->connect(%memory);
2592
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
2593
+$dbi->execute($create_table1_2);
2593 2594
 $dbi->model('table1')->insert(
2594 2595
     id => [1, 2],
2595 2596
     param => {key3 => 3}
... ...
@@ -2601,7 +2602,7 @@ is($row->{key2}, 2);
2601 2602
 is($row->{key3}, 3);
2602 2603
 
2603 2604
 $dbi = MyDBI6->connect(%memory);
2604
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
2605
+$dbi->execute($create_table1_2);
2605 2606
 $dbi->model('table1')->insert(
2606 2607
     {key3 => 3},
2607 2608
     id => [1, 2]
... ...
@@ -2614,7 +2615,7 @@ is($row->{key3}, 3);
2614 2615
 
2615 2616
 test 'update and id option';
2616 2617
 $dbi = DBIx::Custom->connect(%memory);
2617
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
2618
+$dbi->execute($create_table1_2);
2618 2619
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2619 2620
 $dbi->update(
2620 2621
     table => 'table1',
... ...
@@ -2639,7 +2640,7 @@ is($dbi->select(table => 'table1')->one->{key2}, 2);
2639 2640
 is($dbi->select(table => 'table1')->one->{key3}, 4);
2640 2641
 
2641 2642
 $dbi = DBIx::Custom->connect(%memory);
2642
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
2643
+$dbi->execute($create_table1_2);
2643 2644
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2644 2645
 $dbi->update(
2645 2646
     {key3 => 4},
... ...
@@ -2654,7 +2655,7 @@ is($dbi->select(table => 'table1')->one->{key3}, 4);
2654 2655
 
2655 2656
 test 'model update and id option';
2656 2657
 $dbi = MyDBI6->connect(%memory);
2657
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
2658
+$dbi->execute($create_table1_2);
2658 2659
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2659 2660
 $dbi->model('table1')->update(
2660 2661
     id => [1, 2],
... ...
@@ -2669,7 +2670,7 @@ is($row->{key3}, 4);
2669 2670
 
2670 2671
 test 'delete and id option';
2671 2672
 $dbi = DBIx::Custom->connect(%memory);
2672
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
2673
+$dbi->execute($create_table1_2);
2673 2674
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2674 2675
 $dbi->delete(
2675 2676
     table => 'table1',
... ...
@@ -2689,7 +2690,7 @@ is_deeply($dbi->select(table => 'table1')->all, []);
2689 2690
 
2690 2691
 test 'model delete and id option';
2691 2692
 $dbi = MyDBI6->connect(%memory);
2692
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
2693
+$dbi->execute($create_table1_2);
2693 2694
 $dbi->execute("create table table2 (key1, key2, key3)");
2694 2695
 $dbi->execute("create table table3 (key1, key2, key3)");
2695 2696
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
... ...
@@ -2705,7 +2706,7 @@ is_deeply($dbi->select(table => 'table1')->all, []);
2705 2706
 
2706 2707
 test 'select and id option';
2707 2708
 $dbi = DBIx::Custom->connect(%memory);
2708
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
2709
+$dbi->execute($create_table1_2);
2709 2710
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2710 2711
 $result = $dbi->select(
2711 2712
     table => 'table1',
... ...
@@ -2744,7 +2745,7 @@ is($row->{key3}, 3);
2744 2745
 
2745 2746
 test 'model select_at';
2746 2747
 $dbi = MyDBI6->connect(%memory);
2747
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
2748
+$dbi->execute($create_table1_2);
2748 2749
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2749 2750
 $result = $dbi->model('table1')->select(id => [1, 2]);
2750 2751
 $row = $result->one;
... ...
@@ -2754,7 +2755,7 @@ is($row->{key3}, 3);
2754 2755
 
2755 2756
 test 'column separator is default .';
2756 2757
 $dbi = MyDBI7->connect(%memory);
2757
-$dbi->execute($create_table_default);
2758
+$dbi->execute($create_table1);
2758 2759
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
2759 2760
 $dbi->setup_model;
2760 2761
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
... ...
@@ -3173,7 +3174,7 @@ is($result->type_rule2_on->fetch_first->[0], '1bde');
3173 3174
 
3174 3175
 test 'separator';
3175 3176
 $dbi = DBIx::Custom->connect(%memory);
3176
-$dbi->execute($create_table_default);
3177
+$dbi->execute($create_table1);
3177 3178
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
3178 3179
 
3179 3180
 $dbi->create_model(
... ...
@@ -3230,7 +3231,7 @@ is_deeply($model2->select->one, {key1 => 1, key3 => 3});
3230 3231
 
3231 3232
 test 'filter_off';
3232 3233
 $dbi = DBIx::Custom->connect(%memory);
3233
-$dbi->execute($create_table_default);
3234
+$dbi->execute($create_table1);
3234 3235
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
3235 3236
 
3236 3237
 $dbi->create_model(
... ...
@@ -3254,7 +3255,7 @@ ok($dbi->can('available_datatype'));
3254 3255
 
3255 3256
 test 'select prefix option';
3256 3257
 $dbi = DBIx::Custom->connect(%memory);
3257
-$dbi->execute($create_table_default);
3258
+$dbi->execute($create_table1);
3258 3259
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3259 3260
 $rows = $dbi->select(prefix => 'key1,', column => 'key2', table => 'table1')->all;
3260 3261
 is_deeply($rows, [{key1 => 1, key2 => 2}], "table");
... ...
@@ -3381,7 +3382,7 @@ is_deeply($result->header, [qw/h1 h2/]);
3381 3382
 
3382 3383
 test 'Named placeholder :name(operater) syntax';
3383 3384
 $dbi->execute('drop table table1');
3384
-$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
3385
+$dbi->execute($create_table1_2);
3385 3386
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
3386 3387
 $dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
3387 3388
 
... ...
@@ -3454,7 +3455,7 @@ $rows = [
3454 3455
 
3455 3456
 test 'result';
3456 3457
 $dbi = DBIx::Custom->connect(%memory);
3457
-$dbi->execute($create_table_default);
3458
+$dbi->execute($create_table1);
3458 3459
 $dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
3459 3460
 $dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
3460 3461
 
... ...
@@ -3490,7 +3491,7 @@ $row = $result->fetch_hash_first;
3490 3491
 ok(!$row, "no row fetch");
3491 3492
 
3492 3493
 $dbi = DBIx::Custom->connect(%memory);
3493
-$dbi->execute($create_table_default);
3494
+$dbi->execute($create_table1);
3494 3495
 $dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
3495 3496
 $dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
3496 3497
 $dbi->insert({key1 => 5, key2 => 6}, table => 'table1');
... ...
@@ -3529,7 +3530,7 @@ eval {$result->fetch_hash_multi};
3529 3530
 like($@, qr/Row count must be specified/, "Not specified row count");
3530 3531
 
3531 3532
 $dbi = DBIx::Custom->connect(%memory);
3532
-$dbi->execute($create_table_default);
3533
+$dbi->execute($create_table1);
3533 3534
 $dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
3534 3535
 $dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
3535 3536