Showing 1 changed files with 72 additions and 72 deletions
+72 -72
t/basic.t
... ...
@@ -59,7 +59,7 @@ my $join;
59 59
 
60 60
 # Prepare table
61 61
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
62
-$dbi->execute($CREATE_TABLE->{0});
62
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
63 63
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
64 64
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
65 65
 
... ...
@@ -91,7 +91,7 @@ is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "all");
91 91
 
92 92
 test 'Insert query return value';
93 93
 $dbi->execute('drop table table1');
94
-$dbi->execute($CREATE_TABLE->{0});
94
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
95 95
 $source = "insert into table1 {insert_param key1 key2}";
96 96
 $query = $dbi->execute($source, {}, query => 1);
97 97
 $ret_val = $dbi->execute($query, param => {key1 => 1, key2 => 2});
... ...
@@ -100,7 +100,7 @@ ok($ret_val);
100 100
 
101 101
 test 'Direct query';
102 102
 $dbi->execute('drop table table1');
103
-$dbi->execute($CREATE_TABLE->{0});
103
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
104 104
 $insert_SOURCE = "insert into table1 {insert_param key1 key2}";
105 105
 $dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2});
106 106
 $result = $dbi->execute('select * from table1;');
... ...
@@ -109,7 +109,7 @@ is_deeply($rows, [{key1 => 1, key2 => 2}]);
109 109
 
110 110
 test 'Filter basic';
111 111
 $dbi->execute('drop table table1');
112
-$dbi->execute($CREATE_TABLE->{0});
112
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
113 113
 $dbi->register_filter(twice       => sub { $_[0] * 2}, 
114 114
                     three_times => sub { $_[0] * 3});
115 115
 
... ...
@@ -123,7 +123,7 @@ is_deeply($rows, [{key1 => 2, key2 => 6}], "filter fetch_filter");
123 123
 $dbi->execute('drop table table1');
124 124
 
125 125
 test 'Filter in';
126
-$dbi->execute($CREATE_TABLE->{0});
126
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
127 127
 $insert_SOURCE  = "insert into table1 {insert_param key1 key2};";
128 128
 $insert_query = $dbi->execute($insert_SOURCE, {}, query => 1);
129 129
 $dbi->execute($insert_query, param => {key1 => 2, key2 => 4});
... ...
@@ -225,7 +225,7 @@ $rows = $result->all;
225 225
 is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
226 226
 
227 227
 $dbi->execute('drop table table1');
228
-$dbi->execute($CREATE_TABLE->{0});
228
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
229 229
 $dbi->insert(table => 'table1', param => {key1 => '2011-10-14 12:19:18', key2 => 2});
230 230
 $source = "select * from table1 where key1 = '2011-10-14 12:19:18' and key2 = :key2";
231 231
 $result = $dbi->execute(
... ...
@@ -237,7 +237,7 @@ $rows = $result->all;
237 237
 is_deeply($rows, [{key1 => '2011-10-14 12:19:18', key2 => 2}]);
238 238
 
239 239
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
240
-$dbi->execute($CREATE_TABLE->{0});
240
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
241 241
 $dbi->insert(table => 'table1', param => {key1 => 'a:b c:d', key2 => 2});
242 242
 $source = "select * from table1 where key1 = 'a\\:b c\\:d' and key2 = :key2";
243 243
 $result = $dbi->execute(
... ...
@@ -258,7 +258,7 @@ ok($@, "create_query invalid SQL template");
258 258
 
259 259
 test 'insert';
260 260
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
261
-$dbi->execute($CREATE_TABLE->{0});
261
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
262 262
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
263 263
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
264 264
 $result = $dbi->execute('select * from table1;');
... ...
@@ -278,7 +278,7 @@ is_deeply($rows, [{key1 => 3, key2 => 4}], "filter");
278 278
 $dbi->default_bind_filter(undef);
279 279
 
280 280
 $dbi->execute('drop table table1');
281
-$dbi->execute($CREATE_TABLE->{0});
281
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
282 282
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, append => '   ');
283 283
 $rows = $dbi->select(table => 'table1')->all;
284 284
 is_deeply($rows, [{key1 => 1, key2 => 2}], 'insert append');
... ...
@@ -299,7 +299,7 @@ $rows   = $result->all;
299 299
 is_deeply($rows, [{select => 2}], "reserved word");
300 300
 
301 301
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
302
-$dbi->execute($CREATE_TABLE->{0});
302
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
303 303
 $dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
304 304
 $dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
305 305
 $result = $dbi->execute('select * from table1;');
... ...
@@ -315,7 +315,7 @@ $rows   = $result->all;
315 315
 is_deeply($rows, [{key1 => 1, key2 => 4}], "basic");
316 316
 
317 317
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
318
-$dbi->execute($CREATE_TABLE->{0});
318
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
319 319
 $dbi->insert(table => 'table1', param => {key1 => \"'1'", key2 => 2});
320 320
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
321 321
 $result = $dbi->execute('select * from table1;');
... ...
@@ -372,7 +372,7 @@ eval{$dbi->update(table => 'table1')};
372 372
 like($@, qr/where/, "not contain where");
373 373
 
374 374
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
375
-$dbi->execute($CREATE_TABLE->{0});
375
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
376 376
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
377 377
 $where = $dbi->where;
378 378
 $where->clause(['and', 'key1 = :key1', 'key2 = :key2']);
... ...
@@ -382,7 +382,7 @@ $result = $dbi->select(table => 'table1');
382 382
 is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where');
383 383
 
384 384
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
385
-$dbi->execute($CREATE_TABLE->{0});
385
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
386 386
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
387 387
 $dbi->update(
388 388
     table => 'table1',
... ...
@@ -396,7 +396,7 @@ $result = $dbi->select(table => 'table1');
396 396
 is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where');
397 397
 
398 398
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
399
-$dbi->execute($CREATE_TABLE->{0});
399
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
400 400
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
401 401
 $where = $dbi->where;
402 402
 $where->clause(['and', 'key2 = :key2']);
... ...
@@ -483,7 +483,7 @@ is_deeply($rows, [{key1 => 1, key2 => 20, key3 => 3, key4 => 4, key5 => 5},
483 483
 
484 484
 test 'delete';
485 485
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
486
-$dbi->execute($CREATE_TABLE->{0});
486
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
487 487
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
488 488
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
489 489
 $dbi->delete(table => 'table1', where => {key1 => 1});
... ...
@@ -513,7 +513,7 @@ eval{$dbi->delete(table => 'table1', where => {key1 => 1}, noexist => 1)};
513 513
 like($@, qr/noexist/, "invalid");
514 514
 
515 515
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
516
-$dbi->execute($CREATE_TABLE->{0});
516
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
517 517
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
518 518
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
519 519
 $where = $dbi->where;
... ...
@@ -524,7 +524,7 @@ $result = $dbi->select(table => 'table1');
524 524
 is_deeply($result->all, [{key1 => 3, key2 => 4}], 'delete() where');
525 525
 
526 526
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
527
-$dbi->execute($CREATE_TABLE->{0});
527
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
528 528
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
529 529
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
530 530
 $dbi->delete(
... ...
@@ -547,7 +547,7 @@ is_deeply($rows, [], "basic");
547 547
 
548 548
 test 'delete error';
549 549
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
550
-$dbi->execute($CREATE_TABLE->{0});
550
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
551 551
 eval{$dbi->delete(table => 'table1')};
552 552
 like($@, qr/"where" must be specified/,
553 553
          "where key-value pairs not specified");
... ...
@@ -567,7 +567,7 @@ is_deeply($rows, [], "reserved word");
567 567
 
568 568
 test 'delete_all';
569 569
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
570
-$dbi->execute($CREATE_TABLE->{0});
570
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
571 571
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
572 572
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
573 573
 $dbi->delete_all(table => 'table1');
... ...
@@ -578,7 +578,7 @@ is_deeply($rows, [], "basic");
578 578
 
579 579
 test 'select';
580 580
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
581
-$dbi->execute($CREATE_TABLE->{0});
581
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
582 582
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
583 583
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
584 584
 $rows = $dbi->select(table => 'table1')->all;
... ...
@@ -638,7 +638,7 @@ $dbi->register_filter(
638 638
     three_times => sub { $_[0] * 3 }
639 639
 );
640 640
 $dbi->default_fetch_filter('twice');
641
-$dbi->execute($CREATE_TABLE->{0});
641
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
642 642
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
643 643
 $result = $dbi->select(table => 'table1');
644 644
 $result->filter({key1 => 'three_times'});
... ...
@@ -656,7 +656,7 @@ is($dbi->filters->{encode_utf8}->('あ'),
656 656
 
657 657
 test 'transaction';
658 658
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
659
-$dbi->execute($CREATE_TABLE->{0});
659
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
660 660
 $dbi->dbh->begin_work;
661 661
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
662 662
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
... ...
@@ -666,7 +666,7 @@ is_deeply(scalar $result->all, [{key1 => 1, key2 => 2}, {key1 => 2, key2 => 3}],
666 666
           "commit");
667 667
 
668 668
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
669
-$dbi->execute($CREATE_TABLE->{0});
669
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
670 670
 $dbi->dbh->begin_work(0);
671 671
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
672 672
 $dbi->dbh->rollback;
... ...
@@ -677,14 +677,14 @@ ok(! $result->fetch_first, "rollback");
677 677
 test 'cache';
678 678
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
679 679
 $dbi->cache(1);
680
-$dbi->execute($CREATE_TABLE->{0});
680
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
681 681
 $source = 'select * from table1 where key1 = :key1 and key2 = :key2;';
682 682
 $dbi->execute($source, {}, query => 1);
683 683
 is_deeply($dbi->{_cached}->{$source}, 
684 684
           {sql => "select * from table1 where key1 = ? and key2 = ?;", columns => ['key1', 'key2'], tables => []}, "cache");
685 685
 
686 686
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
687
-$dbi->execute($CREATE_TABLE->{0});
687
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
688 688
 $dbi->{_cached} = {};
689 689
 $dbi->cache(0);
690 690
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
... ...
@@ -692,7 +692,7 @@ is(scalar keys %{$dbi->{_cached}}, 0, 'not cache');
692 692
 
693 693
 test 'execute';
694 694
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
695
-$dbi->execute($CREATE_TABLE->{0});
695
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
696 696
 {
697 697
     local $Carp::Verbose = 0;
698 698
     eval{$dbi->execute('select * frm table1')};
... ...
@@ -727,7 +727,7 @@ ok($@, "execute fail");
727 727
 
728 728
 test 'transaction';
729 729
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
730
-$dbi->execute($CREATE_TABLE->{0});
730
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
731 731
 
732 732
 $dbi->begin_work;
733 733
 
... ...
@@ -786,7 +786,7 @@ ok($@, "not exists");
786 786
 
787 787
 test 'out filter';
788 788
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
789
-$dbi->execute($CREATE_TABLE->{0});
789
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
790 790
 $dbi->register_filter(twice => sub { $_[0] * 2 });
791 791
 $dbi->register_filter(three_times => sub { $_[0] * 3});
792 792
 $dbi->apply_filter(
... ...
@@ -801,7 +801,7 @@ $row   = $result->one;
801 801
 is_deeply($row, {key1 => 6, key2 => 12}, "insert");
802 802
 
803 803
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
804
-$dbi->execute($CREATE_TABLE->{0});
804
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
805 805
 $dbi->register_filter(twice => sub { $_[0] * 2 });
806 806
 $dbi->register_filter(three_times => sub { $_[0] * 3});
807 807
 $dbi->apply_filter(
... ...
@@ -816,7 +816,7 @@ $row   = $result->one;
816 816
 is_deeply($row, {key1 => 1, key2 => 6}, "insert");
817 817
 
818 818
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
819
-$dbi->execute($CREATE_TABLE->{0});
819
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
820 820
 $dbi->register_filter(twice => sub { $_[0] * 2 });
821 821
 $dbi->apply_filter(
822 822
     'table1', 'key1' => {out => 'twice', in => 'twice'}
... ...
@@ -828,7 +828,7 @@ $row   = $result->one;
828 828
 is_deeply($row, {key1 => 4, key2 => 2}, "update");
829 829
 
830 830
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
831
-$dbi->execute($CREATE_TABLE->{0});
831
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
832 832
 $dbi->register_filter(twice => sub { $_[0] * 2 });
833 833
 $dbi->apply_filter(
834 834
     'table1', 'key1' => {out => 'twice', in => 'twice'}
... ...
@@ -840,7 +840,7 @@ $rows   = $result->all;
840 840
 is_deeply($rows, [], "delete");
841 841
 
842 842
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
843
-$dbi->execute($CREATE_TABLE->{0});
843
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
844 844
 $dbi->register_filter(twice => sub { $_[0] * 2 });
845 845
 $dbi->apply_filter(
846 846
     'table1', 'key1' => {out => 'twice', in => 'twice'}
... ...
@@ -852,7 +852,7 @@ $rows   = $result->all;
852 852
 is_deeply($rows, [{key1 => 4, key2 => 4}], "select");
853 853
 
854 854
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
855
-$dbi->execute($CREATE_TABLE->{0});
855
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
856 856
 $dbi->register_filter(twice => sub { $_[0] * 2 });
857 857
 $dbi->apply_filter(
858 858
     'table1', 'key1' => {out => 'twice', in => 'twice'}
... ...
@@ -865,7 +865,7 @@ $rows   = $result->all;
865 865
 is_deeply($rows, [{key1 => 4, key2 => 2}], "execute");
866 866
 
867 867
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
868
-$dbi->execute($CREATE_TABLE->{0});
868
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
869 869
 $dbi->register_filter(twice => sub { $_[0] * 2 });
870 870
 $dbi->apply_filter(
871 871
     'table1', 'key1' => {out => 'twice', in => 'twice'}
... ...
@@ -877,7 +877,7 @@ $rows   = $result->all;
877 877
 is_deeply($rows, [{key1 => 4, key2 => 2}], "execute table tag");
878 878
 
879 879
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
880
-$dbi->execute($CREATE_TABLE->{0});
880
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
881 881
 $dbi->execute($CREATE_TABLE->{2});
882 882
 $dbi->register_filter(twice => sub { $_[0] * 2 });
883 883
 $dbi->register_filter(three_times => sub { $_[0] * 3 });
... ...
@@ -955,7 +955,7 @@ is_deeply($infos,
955 955
 
956 956
 test 'limit';
957 957
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
958
-$dbi->execute($CREATE_TABLE->{0});
958
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
959 959
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
960 960
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 4});
961 961
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 6});
... ...
@@ -1008,13 +1008,13 @@ test 'connect super';
1008 1008
 }
1009 1009
 
1010 1010
 $dbi = MyDBI->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1011
-$dbi->execute($CREATE_TABLE->{0});
1011
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1012 1012
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1013 1013
 is($dbi->select(table => 'table1')->one->{key1}, 1);
1014 1014
 
1015 1015
 $dbi = MyDBI->new(dsn => 'dbi:SQLite:dbname=:memory:');
1016 1016
 $dbi->connect;
1017
-$dbi->execute($CREATE_TABLE->{0});
1017
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1018 1018
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1019 1019
 is($dbi->select(table => 'table1')->one->{key1}, 1);
1020 1020
 
... ...
@@ -1031,13 +1031,13 @@ is($dbi->select(table => 'table1')->one->{key1}, 1);
1031 1031
 }
1032 1032
 
1033 1033
 $dbi = MyDBI->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1034
-$dbi->execute($CREATE_TABLE->{0});
1034
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1035 1035
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1036 1036
 is($dbi->select(table => 'table1')->one->{key1}, 1);
1037 1037
 
1038 1038
 test 'end_filter';
1039 1039
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1040
-$dbi->execute($CREATE_TABLE->{0});
1040
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1041 1041
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1042 1042
 $result = $dbi->select(table => 'table1');
1043 1043
 $result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 });
... ...
@@ -1046,7 +1046,7 @@ $row = $result->fetch_first;
1046 1046
 is_deeply($row, [6, 40]);
1047 1047
 
1048 1048
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1049
-$dbi->execute($CREATE_TABLE->{0});
1049
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1050 1050
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1051 1051
 $result = $dbi->select(table => 'table1');
1052 1052
 $result->filter([qw/key1 key2/] => sub { $_[0] * 2 });
... ...
@@ -1055,7 +1055,7 @@ $row = $result->fetch_first;
1055 1055
 is_deeply($row, [6, 12]);
1056 1056
 
1057 1057
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1058
-$dbi->execute($CREATE_TABLE->{0});
1058
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1059 1059
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1060 1060
 $result = $dbi->select(table => 'table1');
1061 1061
 $result->filter([[qw/key1 key2/] => sub { $_[0] * 2 }]);
... ...
@@ -1094,7 +1094,7 @@ is_deeply($row, {key1 => 1, key2 => 40}, 'apply_filter overwrite');
1094 1094
 
1095 1095
 test 'remove_end_filter and remove_filter';
1096 1096
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1097
-$dbi->execute($CREATE_TABLE->{0});
1097
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1098 1098
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1099 1099
 $result = $dbi->select(table => 'table1');
1100 1100
 $row = $result
... ...
@@ -1107,7 +1107,7 @@ is_deeply($row, [1, 2]);
1107 1107
 
1108 1108
 test 'empty where select';
1109 1109
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1110
-$dbi->execute($CREATE_TABLE->{0});
1110
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1111 1111
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1112 1112
 $result = $dbi->select(table => 'table1', where => {});
1113 1113
 $row = $result->one;
... ...
@@ -1115,7 +1115,7 @@ is_deeply($row, {key1 => 1, key2 => 2});
1115 1115
 
1116 1116
 test 'select query option';
1117 1117
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1118
-$dbi->execute($CREATE_TABLE->{0});
1118
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1119 1119
 $query = $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, query => 1);
1120 1120
 is(ref $query, 'DBIx::Custom::Query');
1121 1121
 $query = $dbi->update(table => 'table1', where => {key1 => 1}, param => {key2 => 2}, query => 1);
... ...
@@ -1127,7 +1127,7 @@ is(ref $query, 'DBIx::Custom::Query');
1127 1127
 
1128 1128
 test 'DBIx::Custom::Where';
1129 1129
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1130
-$dbi->execute($CREATE_TABLE->{0});
1130
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1131 1131
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1132 1132
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1133 1133
 $where = $dbi->where->clause(['and', 'key1 = :key1', 'key2 = :key2']);
... ...
@@ -1455,7 +1455,7 @@ $dbi->apply_filter(
1455 1455
 
1456 1456
 );
1457 1457
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1458
-$dbi->execute($CREATE_TABLE->{0});
1458
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1459 1459
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1460 1460
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1461 1461
 $dbi->apply_filter('table1', 'key2', 
... ...
@@ -1464,7 +1464,7 @@ $rows = $dbi->select(table => 'table1', where => {key2 => 1})->all;
1464 1464
 is_deeply($rows, [{key1 => 1, key2 => 6}]);
1465 1465
 
1466 1466
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1467
-$dbi->execute($CREATE_TABLE->{0});
1467
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1468 1468
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1469 1469
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1470 1470
 $dbi->apply_filter('table1', 'key2', {});
... ...
@@ -1483,7 +1483,7 @@ eval{DBIx::Custom->connect()};
1483 1483
 like($@, qr/_connect/);
1484 1484
 
1485 1485
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1486
-$dbi->execute($CREATE_TABLE->{0});
1486
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1487 1487
 $dbi->register_filter(twice => sub { $_[0] * 2 });
1488 1488
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2},
1489 1489
              filter => {key1 => 'twice'});
... ...
@@ -1510,7 +1510,7 @@ eval {$dbi->execute('select * from table1 {} {= author') };
1510 1510
 like($@, qr/Tag not finished/);
1511 1511
 
1512 1512
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1513
-$dbi->execute($CREATE_TABLE->{0});
1513
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1514 1514
 $dbi->register_filter(one => sub { 1 });
1515 1515
 $result = $dbi->select(table => 'table1');
1516 1516
 eval {$result->filter(key1 => 'no')};
... ...
@@ -1962,7 +1962,7 @@ test 'mycolumn and column';
1962 1962
     }
1963 1963
 }
1964 1964
 $dbi = MyDBI7->connect(dsn => 'dbi:SQLite:dbname=:memory:');
1965
-$dbi->execute($CREATE_TABLE->{0});
1965
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
1966 1966
 $dbi->execute($CREATE_TABLE->{2});
1967 1967
 $dbi->separator('__');
1968 1968
 $dbi->setup_model;
... ...
@@ -2087,7 +2087,7 @@ like($@, qr/not safety/);
2087 2087
 
2088 2088
 test 'join';
2089 2089
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2090
-$dbi->execute($CREATE_TABLE->{0});
2090
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2091 2091
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2092 2092
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
2093 2093
 $dbi->execute($CREATE_TABLE->{2});
... ...
@@ -2147,7 +2147,7 @@ is_deeply($rows, [{table1__key1 => 1}]);
2147 2147
 
2148 2148
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2149 2149
 $dbi->quote('"');
2150
-$dbi->execute($CREATE_TABLE->{0});
2150
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2151 2151
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2152 2152
 $dbi->execute($CREATE_TABLE->{2});
2153 2153
 $dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5});
... ...
@@ -2175,7 +2175,7 @@ is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}],
2175 2175
 }
2176 2176
 
2177 2177
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2178
-$dbi->execute($CREATE_TABLE->{0});
2178
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2179 2179
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2180 2180
 $sql = <<"EOS";
2181 2181
 left outer join (
... ...
@@ -2195,7 +2195,7 @@ $rows = $dbi->select(
2195 2195
 is_deeply($rows, [{latest_table1__key1 => 1}]);
2196 2196
 
2197 2197
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2198
-$dbi->execute($CREATE_TABLE->{0});
2198
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2199 2199
 $dbi->execute($CREATE_TABLE->{2});
2200 2200
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2201 2201
 $dbi->insert(table => 'table2', param => {key1 => 1, key3 => 4});
... ...
@@ -2225,7 +2225,7 @@ $result = $dbi->select(
2225 2225
 is_deeply($result->all, [{'table2.key3' => 4}]);
2226 2226
 
2227 2227
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2228
-$dbi->execute($CREATE_TABLE->{0});
2228
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2229 2229
 $dbi->execute($CREATE_TABLE->{2});
2230 2230
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2231 2231
 $dbi->insert(table => 'table2', param => {key1 => 1, key3 => 4});
... ...
@@ -2244,7 +2244,7 @@ is_deeply($result->all, [{'table2.key3' => 4}]);
2244 2244
 
2245 2245
 test 'mycolumn';
2246 2246
 $dbi = MyDBI8->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2247
-$dbi->execute($CREATE_TABLE->{0});
2247
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2248 2248
 $dbi->execute($CREATE_TABLE->{2});
2249 2249
 $dbi->setup_model;
2250 2250
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
... ...
@@ -2309,14 +2309,14 @@ test 'dbi method from model';
2309 2309
     }
2310 2310
 }
2311 2311
 $dbi = MyDBI9->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2312
-$dbi->execute($CREATE_TABLE->{0});
2312
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2313 2313
 $model = $dbi->model('table1');
2314 2314
 eval{$model->execute('select * from table1')};
2315 2315
 ok(!$@);
2316 2316
 
2317 2317
 test 'column table option';
2318 2318
 $dbi = MyDBI9->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2319
-$dbi->execute($CREATE_TABLE->{0});
2319
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2320 2320
 $dbi->execute($CREATE_TABLE->{2});
2321 2321
 $dbi->setup_model;
2322 2322
 $dbi->execute('insert into table1 (key1, key2) values (1, 2);');
... ...
@@ -2422,7 +2422,7 @@ is($row->{key1_length}, length $binary);
2422 2422
 
2423 2423
 test 'create_model';
2424 2424
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2425
-$dbi->execute($CREATE_TABLE->{0});
2425
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2426 2426
 $dbi->execute($CREATE_TABLE->{2});
2427 2427
 
2428 2428
 $dbi->create_model(
... ...
@@ -2484,7 +2484,7 @@ test 'merge_param';
2484 2484
 
2485 2485
 test 'select() param option';
2486 2486
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2487
-$dbi->execute($CREATE_TABLE->{0});
2487
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2488 2488
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2489 2489
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2490 2490
 $dbi->execute($CREATE_TABLE->{2});
... ...
@@ -2503,7 +2503,7 @@ is_deeply($rows, [{table1_key1 => 2, key2 => 3, key3 => 5}]);
2503 2503
 
2504 2504
 test 'select() wrap option';
2505 2505
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2506
-$dbi->execute($CREATE_TABLE->{0});
2506
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2507 2507
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2508 2508
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2509 2509
 $rows = $dbi->select(
... ...
@@ -2524,7 +2524,7 @@ like($@, qr/array/);
2524 2524
 
2525 2525
 test 'select() string where';
2526 2526
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2527
-$dbi->execute($CREATE_TABLE->{0});
2527
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2528 2528
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2529 2529
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2530 2530
 $rows = $dbi->select(
... ...
@@ -2535,7 +2535,7 @@ $rows = $dbi->select(
2535 2535
 is_deeply($rows, [{key1 => 1, key2 => 2}]);
2536 2536
 
2537 2537
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2538
-$dbi->execute($CREATE_TABLE->{0});
2538
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2539 2539
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2540 2540
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2541 2541
 $rows = $dbi->select(
... ...
@@ -2549,7 +2549,7 @@ is_deeply($rows, [{key1 => 1, key2 => 2}]);
2549 2549
 
2550 2550
 test 'delete() string where';
2551 2551
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2552
-$dbi->execute($CREATE_TABLE->{0});
2552
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2553 2553
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2554 2554
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2555 2555
 $dbi->delete(
... ...
@@ -2561,7 +2561,7 @@ $rows = $dbi->select(table => 'table1')->all;
2561 2561
 is_deeply($rows, [{key1 => 2, key2 => 3}]);
2562 2562
 
2563 2563
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2564
-$dbi->execute($CREATE_TABLE->{0});
2564
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2565 2565
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2566 2566
 $dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2567 2567
 $dbi->delete(
... ...
@@ -2577,7 +2577,7 @@ is_deeply($rows, [{key1 => 2, key2 => 3}]);
2577 2577
 
2578 2578
 test 'update() string where';
2579 2579
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2580
-$dbi->execute($CREATE_TABLE->{0});
2580
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2581 2581
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2582 2582
 $dbi->update(
2583 2583
     table => 'table1',
... ...
@@ -2589,7 +2589,7 @@ $rows = $dbi->select(table => 'table1')->all;
2589 2589
 is_deeply($rows, [{key1 => 5, key2 => 2}]);
2590 2590
 
2591 2591
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2592
-$dbi->execute($CREATE_TABLE->{0});
2592
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2593 2593
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2594 2594
 $dbi->update(
2595 2595
     table => 'table1',
... ...
@@ -2807,7 +2807,7 @@ is($row->{key3}, 3);
2807 2807
 
2808 2808
 test 'column separator is default .';
2809 2809
 $dbi = MyDBI7->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2810
-$dbi->execute($CREATE_TABLE->{0});
2810
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2811 2811
 $dbi->execute($CREATE_TABLE->{2});
2812 2812
 $dbi->setup_model;
2813 2813
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
... ...
@@ -3226,7 +3226,7 @@ is($result->type_rule2_on->fetch_first->[0], '1bde');
3226 3226
 
3227 3227
 test 'separator';
3228 3228
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
3229
-$dbi->execute($CREATE_TABLE->{0});
3229
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
3230 3230
 $dbi->execute($CREATE_TABLE->{2});
3231 3231
 
3232 3232
 $dbi->create_model(
... ...
@@ -3283,7 +3283,7 @@ is_deeply($model2->select->one, {key1 => 1, key3 => 3});
3283 3283
 
3284 3284
 test 'filter_off';
3285 3285
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
3286
-$dbi->execute($CREATE_TABLE->{0});
3286
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
3287 3287
 $dbi->execute($CREATE_TABLE->{2});
3288 3288
 
3289 3289
 $dbi->create_model(
... ...
@@ -3307,7 +3307,7 @@ ok($dbi->can('available_data_type'));
3307 3307
 
3308 3308
 test 'select prefix option';
3309 3309
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
3310
-$dbi->execute($CREATE_TABLE->{0});
3310
+$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
3311 3311
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3312 3312
 $rows = $dbi->select(prefix => 'key1,', column => 'key2', table => 'table1')->all;
3313 3313
 is_deeply($rows, [{key1 => 1, key2 => 2}], "table");