...
|
...
|
@@ -25,7 +25,6 @@ sub test { print "# $_[0]\n" }
|
25
|
25
|
}
|
26
|
26
|
|
27
|
27
|
# Constant
|
28
|
|
-my %memory = (dsn => 'dbi:SQLite:dbname=:memory:');
|
29
|
28
|
my $create_table1 = 'create table table1 (key1 char(255), key2 char(255));';
|
30
|
29
|
my $create_table1_2 = 'create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));';
|
31
|
30
|
my $q = '"';
|
...
|
...
|
@@ -63,7 +62,7 @@ my $insert_param;
|
63
|
62
|
my $join;
|
64
|
63
|
|
65
|
64
|
# Prepare table
|
66
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
65
|
+$dbi = DBIx::Custom->connect;
|
67
|
66
|
|
68
|
67
|
=pod
|
69
|
68
|
|
...
|
...
|
@@ -367,7 +366,7 @@ like($@, qr/"where" must be specified/,
|
367
|
366
|
eval{$dbi->delete(table => 'table1', where => {';' => 1})};
|
368
|
367
|
like($@, qr/safety/);
|
369
|
368
|
|
370
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
369
|
+$dbi = DBIx::Custom->connect;
|
371
|
370
|
$dbi->quote('"');
|
372
|
371
|
$dbi->execute('create table "table" ("select", "update")');
|
373
|
372
|
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
|
...
|
...
|
@@ -434,7 +433,7 @@ is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "
|
434
|
433
|
eval{$dbi->select(table => 'table1', noexist => 1)};
|
435
|
434
|
like($@, qr/noexist/, "invalid");
|
436
|
435
|
|
437
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
436
|
+$dbi = DBIx::Custom->connect;
|
438
|
437
|
$dbi->quote('"');
|
439
|
438
|
$dbi->execute('create table "table" ("select", "update")');
|
440
|
439
|
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
|
...
|
...
|
@@ -467,7 +466,7 @@ is($dbi->filters->{encode_utf8}->('あ'),
|
467
|
466
|
encode_utf8('あ'), "encode_utf8");
|
468
|
467
|
|
469
|
468
|
test 'transaction';
|
470
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
469
|
+$dbi = DBIx::Custom->connect;
|
471
|
470
|
$dbi->execute($create_table1);
|
472
|
471
|
$dbi->dbh->begin_work;
|
473
|
472
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
...
|
...
|
@@ -477,7 +476,7 @@ $result = $dbi->select(table => 'table1');
|
477
|
476
|
is_deeply(scalar $result->all, [{key1 => 1, key2 => 2}, {key1 => 2, key2 => 3}],
|
478
|
477
|
"commit");
|
479
|
478
|
|
480
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
479
|
+$dbi = DBIx::Custom->connect;
|
481
|
480
|
$dbi->execute($create_table1);
|
482
|
481
|
$dbi->dbh->begin_work(0);
|
483
|
482
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
...
|
...
|
@@ -538,7 +537,7 @@ ok($@, "execute fail");
|
538
|
537
|
|
539
|
538
|
|
540
|
539
|
test 'transaction';
|
541
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
540
|
+$dbi = DBIx::Custom->connect;
|
542
|
541
|
$dbi->execute($create_table1);
|
543
|
542
|
|
544
|
543
|
$dbi->begin_work;
|
...
|
...
|
@@ -612,7 +611,7 @@ $result = $dbi->select(table => 'table1');
|
612
|
611
|
$row = $result->one;
|
613
|
612
|
is_deeply($row, {key1 => 6, key2 => 12}, "insert");
|
614
|
613
|
|
615
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
614
|
+$dbi = DBIx::Custom->connect;
|
616
|
615
|
eval { $dbi->execute('drop table table1') };
|
617
|
616
|
$dbi->execute($create_table1);
|
618
|
617
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
...
|
...
|
@@ -628,7 +627,7 @@ $result = $dbi->execute('select * from table1;');
|
628
|
627
|
$row = $result->one;
|
629
|
628
|
is_deeply($row, {key1 => 1, key2 => 6}, "insert");
|
630
|
629
|
|
631
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
630
|
+$dbi = DBIx::Custom->connect;
|
632
|
631
|
eval { $dbi->execute('drop table table1') };
|
633
|
632
|
$dbi->execute($create_table1);
|
634
|
633
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
...
|
...
|
@@ -641,7 +640,7 @@ $result = $dbi->execute('select * from table1;');
|
641
|
640
|
$row = $result->one;
|
642
|
641
|
is_deeply($row, {key1 => 4, key2 => 2}, "update");
|
643
|
642
|
|
644
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
643
|
+$dbi = DBIx::Custom->connect;
|
645
|
644
|
$dbi->execute($create_table1);
|
646
|
645
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
647
|
646
|
$dbi->apply_filter(
|
...
|
...
|
@@ -653,7 +652,7 @@ $result = $dbi->execute('select * from table1;');
|
653
|
652
|
$rows = $result->all;
|
654
|
653
|
is_deeply($rows, [], "delete");
|
655
|
654
|
|
656
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
655
|
+$dbi = DBIx::Custom->connect;
|
657
|
656
|
$dbi->execute($create_table1);
|
658
|
657
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
659
|
658
|
$dbi->apply_filter(
|
...
|
...
|
@@ -665,7 +664,7 @@ $result->filter({'key2' => 'twice'});
|
665
|
664
|
$rows = $result->all;
|
666
|
665
|
is_deeply($rows, [{key1 => 4, key2 => 4}], "select");
|
667
|
666
|
|
668
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
667
|
+$dbi = DBIx::Custom->connect;
|
669
|
668
|
$dbi->execute($create_table1);
|
670
|
669
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
671
|
670
|
$dbi->apply_filter(
|
...
|
...
|
@@ -678,7 +677,7 @@ $result = $dbi->execute("select * from table1 where key1 = :key1 and key2 = :key
|
678
|
677
|
$rows = $result->all;
|
679
|
678
|
is_deeply($rows, [{key1 => 4, key2 => 2}], "execute");
|
680
|
679
|
|
681
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
680
|
+$dbi = DBIx::Custom->connect;
|
682
|
681
|
$dbi->execute($create_table1);
|
683
|
682
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
684
|
683
|
$dbi->apply_filter(
|
...
|
...
|
@@ -690,7 +689,7 @@ $result = $dbi->execute("select * from {table table1} where key1 = :key1 and key
|
690
|
689
|
$rows = $result->all;
|
691
|
690
|
is_deeply($rows, [{key1 => 4, key2 => 2}], "execute table tag");
|
692
|
691
|
|
693
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
692
|
+$dbi = DBIx::Custom->connect;
|
694
|
693
|
$dbi->execute($create_table1);
|
695
|
694
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
696
|
695
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
...
|
...
|
@@ -722,7 +721,7 @@ $rows = $result->all;
|
722
|
721
|
is_deeply($rows, [{key2 => 4, key3 => 18}], "select : join : omit");
|
723
|
722
|
|
724
|
723
|
test 'each_column';
|
725
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
724
|
+$dbi = DBIx::Custom->connect;
|
726
|
725
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
727
|
726
|
$dbi->execute('create table table1 (key1 Date, key2 datetime);');
|
728
|
727
|
|
...
|
...
|
@@ -746,7 +745,7 @@ is_deeply($infos,
|
746
|
745
|
|
747
|
746
|
);
|
748
|
747
|
test 'each_table';
|
749
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
748
|
+$dbi = DBIx::Custom->connect;
|
750
|
749
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
751
|
750
|
$dbi->execute('create table table1 (key1 Date, key2 datetime);');
|
752
|
751
|
|
...
|
...
|
@@ -768,7 +767,7 @@ is_deeply($infos,
|
768
|
767
|
);
|
769
|
768
|
|
770
|
769
|
test 'limit';
|
771
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
770
|
+$dbi = DBIx::Custom->connect;
|
772
|
771
|
$dbi->execute($create_table1);
|
773
|
772
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
774
|
773
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 4});
|
...
|
...
|
@@ -821,12 +820,12 @@ test 'connect super';
|
821
|
820
|
}
|
822
|
821
|
}
|
823
|
822
|
|
824
|
|
-$dbi = MyDBI->connect(%memory);
|
|
823
|
+$dbi = MyDBI->connect;
|
825
|
824
|
$dbi->execute($create_table1);
|
826
|
825
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
827
|
826
|
is($dbi->select(table => 'table1')->one->{key1}, 1);
|
828
|
827
|
|
829
|
|
-$dbi = MyDBI->new(%memory);
|
|
828
|
+$dbi = MyDBI->new;
|
830
|
829
|
$dbi->connect;
|
831
|
830
|
$dbi->execute($create_table1);
|
832
|
831
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
...
|
...
|
@@ -844,13 +843,13 @@ is($dbi->select(table => 'table1')->one->{key1}, 1);
|
844
|
843
|
}
|
845
|
844
|
}
|
846
|
845
|
|
847
|
|
-$dbi = MyDBI->connect(%memory);
|
|
846
|
+$dbi = MyDBI->connect;
|
848
|
847
|
$dbi->execute($create_table1);
|
849
|
848
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
850
|
849
|
is($dbi->select(table => 'table1')->one->{key1}, 1);
|
851
|
850
|
|
852
|
851
|
test 'end_filter';
|
853
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
852
|
+$dbi = DBIx::Custom->connect;
|
854
|
853
|
$dbi->execute($create_table1);
|
855
|
854
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
856
|
855
|
$result = $dbi->select(table => 'table1');
|
...
|
...
|
@@ -859,7 +858,7 @@ $result->end_filter(key1 => sub { $_[0] * 3 }, key2 => sub { $_[0] * 5 });
|
859
|
858
|
$row = $result->fetch_first;
|
860
|
859
|
is_deeply($row, [6, 40]);
|
861
|
860
|
|
862
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
861
|
+$dbi = DBIx::Custom->connect;
|
863
|
862
|
$dbi->execute($create_table1);
|
864
|
863
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
865
|
864
|
$result = $dbi->select(table => 'table1');
|
...
|
...
|
@@ -868,7 +867,7 @@ $result->end_filter([[qw/key1 key2/] => sub { $_[0] * 3 }]);
|
868
|
867
|
$row = $result->fetch_first;
|
869
|
868
|
is_deeply($row, [6, 12]);
|
870
|
869
|
|
871
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
870
|
+$dbi = DBIx::Custom->connect;
|
872
|
871
|
$dbi->execute($create_table1);
|
873
|
872
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
874
|
873
|
$result = $dbi->select(table => 'table1');
|
...
|
...
|
@@ -907,7 +906,7 @@ $row = $result->one;
|
907
|
906
|
is_deeply($row, {key1 => 1, key2 => 40}, 'apply_filter overwrite');
|
908
|
907
|
|
909
|
908
|
test 'remove_end_filter and remove_filter';
|
910
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
909
|
+$dbi = DBIx::Custom->connect;
|
911
|
910
|
$dbi->execute($create_table1);
|
912
|
911
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
913
|
912
|
$result = $dbi->select(table => 'table1');
|
...
|
...
|
@@ -920,7 +919,7 @@ $row = $result
|
920
|
919
|
is_deeply($row, [1, 2]);
|
921
|
920
|
|
922
|
921
|
test 'empty where select';
|
923
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
922
|
+$dbi = DBIx::Custom->connect;
|
924
|
923
|
$dbi->execute($create_table1);
|
925
|
924
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
926
|
925
|
$result = $dbi->select(table => 'table1', where => {});
|
...
|
...
|
@@ -928,7 +927,7 @@ $row = $result->one;
|
928
|
927
|
is_deeply($row, {key1 => 1, key2 => 2});
|
929
|
928
|
|
930
|
929
|
test 'select query option';
|
931
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
930
|
+$dbi = DBIx::Custom->connect;
|
932
|
931
|
$dbi->execute($create_table1);
|
933
|
932
|
$query = $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, query => 1);
|
934
|
933
|
is(ref $query, 'DBIx::Custom::Query');
|
...
|
...
|
@@ -940,7 +939,7 @@ $query = $dbi->select(table => 'table1', where => {key1 => 1, key2 => 2}, query
|
940
|
939
|
is(ref $query, 'DBIx::Custom::Query');
|
941
|
940
|
|
942
|
941
|
test 'where';
|
943
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
942
|
+$dbi = DBIx::Custom->connect;
|
944
|
943
|
$dbi->execute($create_table1);
|
945
|
944
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
946
|
945
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
...
|
...
|
@@ -1378,21 +1377,21 @@ $dbi = DBIx::Custom->new;
|
1378
|
1377
|
is_deeply($dbi->dbi_option, {});
|
1379
|
1378
|
|
1380
|
1379
|
test 'register_tag_processor';
|
1381
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1380
|
+$dbi = DBIx::Custom->connect;
|
1382
|
1381
|
$dbi->register_tag_processor(
|
1383
|
1382
|
a => sub { 1 }
|
1384
|
1383
|
);
|
1385
|
1384
|
is($dbi->query_builder->tag_processors->{a}->(), 1);
|
1386
|
1385
|
|
1387
|
1386
|
test 'register_tag';
|
1388
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1387
|
+$dbi = DBIx::Custom->connect;
|
1389
|
1388
|
$dbi->register_tag(
|
1390
|
1389
|
b => sub { 2 }
|
1391
|
1390
|
);
|
1392
|
1391
|
is($dbi->query_builder->tags->{b}->(), 2);
|
1393
|
1392
|
|
1394
|
1393
|
test 'table not specify exception';
|
1395
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1394
|
+$dbi = DBIx::Custom->connect;
|
1396
|
1395
|
eval {$dbi->insert};
|
1397
|
1396
|
like($@, qr/table/);
|
1398
|
1397
|
eval {$dbi->update};
|
...
|
...
|
@@ -1404,7 +1403,7 @@ like($@, qr/table/);
|
1404
|
1403
|
|
1405
|
1404
|
|
1406
|
1405
|
test 'more tests';
|
1407
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1406
|
+$dbi = DBIx::Custom->connect;
|
1408
|
1407
|
eval{$dbi->apply_filter('table', 'column', [])};
|
1409
|
1408
|
like($@, qr/apply_filter/);
|
1410
|
1409
|
|
...
|
...
|
@@ -1414,7 +1413,7 @@ like($@, qr/apply_filter/);
|
1414
|
1413
|
$dbi->apply_filter(
|
1415
|
1414
|
|
1416
|
1415
|
);
|
1417
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1416
|
+$dbi = DBIx::Custom->connect;
|
1418
|
1417
|
$dbi->execute($create_table1);
|
1419
|
1418
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
1420
|
1419
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
...
|
...
|
@@ -1423,7 +1422,7 @@ $dbi->apply_filter('table1', 'key2',
|
1423
|
1422
|
$rows = $dbi->select(table => 'table1', where => {key2 => 1})->all;
|
1424
|
1423
|
is_deeply($rows, [{key1 => 1, key2 => 6}]);
|
1425
|
1424
|
|
1426
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1425
|
+$dbi = DBIx::Custom->connect;
|
1427
|
1426
|
$dbi->execute($create_table1);
|
1428
|
1427
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
1429
|
1428
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
...
|
...
|
@@ -1431,7 +1430,7 @@ $dbi->apply_filter('table1', 'key2', {});
|
1431
|
1430
|
$rows = $dbi->select(table => 'table1', where => {key2 => 2})->all;
|
1432
|
1431
|
is_deeply($rows, [{key1 => 1, key2 => 2}]);
|
1433
|
1432
|
|
1434
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1433
|
+$dbi = DBIx::Custom->connect;
|
1435
|
1434
|
eval {$dbi->apply_filter('table1', 'key2', {out => 'no'})};
|
1436
|
1435
|
like($@, qr/not registered/);
|
1437
|
1436
|
eval {$dbi->apply_filter('table1', 'key2', {in => 'no'})};
|
...
|
...
|
@@ -1442,7 +1441,7 @@ is($dbi->one, 1);
|
1442
|
1441
|
eval{DBIx::Custom->connect(dsn => undef)};
|
1443
|
1442
|
like($@, qr/_connect/);
|
1444
|
1443
|
|
1445
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1444
|
+$dbi = DBIx::Custom->connect;
|
1446
|
1445
|
$dbi->execute($create_table1);
|
1447
|
1446
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
1448
|
1447
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2},
|
...
|
...
|
@@ -1469,7 +1468,7 @@ ok(!defined $dbi->default_fetch_filter);
|
1469
|
1468
|
eval {$dbi->execute('select * from table1 {} {= author') };
|
1470
|
1469
|
like($@, qr/Tag not finished/);
|
1471
|
1470
|
|
1472
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1471
|
+$dbi = DBIx::Custom->connect;
|
1473
|
1472
|
$dbi->execute($create_table1);
|
1474
|
1473
|
$dbi->register_filter(one => sub { 1 });
|
1475
|
1474
|
$result = $dbi->select(table => 'table1');
|
...
|
...
|
@@ -1483,11 +1482,9 @@ $result->default_filter('one');
|
1483
|
1482
|
is($result->default_filter->(), 1);
|
1484
|
1483
|
|
1485
|
1484
|
test 'dbi_option';
|
1486
|
|
-$dbi = DBIx::Custom->connect(%memory,
|
1487
|
|
- dbi_option => {PrintError => 1});
|
|
1485
|
+$dbi = DBIx::Custom->connect(dbi_option => {PrintError => 1});
|
1488
|
1486
|
ok($dbi->dbh->{PrintError});
|
1489
|
|
-$dbi = DBIx::Custom->connect(%memory,
|
1490
|
|
- dbi_options => {PrintError => 1});
|
|
1487
|
+$dbi = DBIx::Custom->connect(dbi_options => {PrintError => 1});
|
1491
|
1488
|
ok($dbi->dbh->{PrintError});
|
1492
|
1489
|
|
1493
|
1490
|
test 'DBIx::Custom::Result stash()';
|
...
|
...
|
@@ -1497,7 +1494,7 @@ $result->stash->{foo} = 1;
|
1497
|
1494
|
is($result->stash->{foo}, 1, 'get and set');
|
1498
|
1495
|
|
1499
|
1496
|
test 'filter __ expression';
|
1500
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1497
|
+$dbi = DBIx::Custom->connect;
|
1501
|
1498
|
$dbi->execute('create table company (id, name, location_id)');
|
1502
|
1499
|
$dbi->execute('create table location (id, name)');
|
1503
|
1500
|
$dbi->apply_filter('location',
|
...
|
...
|
@@ -1527,7 +1524,7 @@ is($result->fetch_first->[0], 'B');
|
1527
|
1524
|
|
1528
|
1525
|
test 'Model class';
|
1529
|
1526
|
use MyDBI1;
|
1530
|
|
-$dbi = MyDBI1->connect(%memory);
|
|
1527
|
+$dbi = MyDBI1->connect;
|
1531
|
1528
|
$dbi->execute("create table book (title, author)");
|
1532
|
1529
|
$model = $dbi->model('book');
|
1533
|
1530
|
$model->insert({title => 'a', author => 'b'});
|
...
|
...
|
@@ -1595,7 +1592,7 @@ is($dbi->models->{'company'}, $dbi->model('company'));
|
1595
|
1592
|
|
1596
|
1593
|
sub list { shift->select; }
|
1597
|
1594
|
}
|
1598
|
|
-$dbi = MyDBI4->connect(%memory);
|
|
1595
|
+$dbi = MyDBI4->connect;
|
1599
|
1596
|
$dbi->execute("create table book (title, author)");
|
1600
|
1597
|
$model = $dbi->model('book');
|
1601
|
1598
|
$model->insert({title => 'a', author => 'b'});
|
...
|
...
|
@@ -1619,7 +1616,7 @@ is_deeply($model->list->all, [{name => 'a'}], 'basic');
|
1619
|
1616
|
$self->include_model('MyModel4');
|
1620
|
1617
|
}
|
1621
|
1618
|
}
|
1622
|
|
-$dbi = MyDBI5->connect(%memory);
|
|
1619
|
+$dbi = MyDBI5->connect;
|
1623
|
1620
|
$dbi->execute("create table company (name)");
|
1624
|
1621
|
$dbi->execute("create table table1 (key1)");
|
1625
|
1622
|
$model = $dbi->model('company');
|
...
|
...
|
@@ -1631,21 +1628,21 @@ is_deeply($model->list->all, [{key1 => 1}], 'include all model');
|
1631
|
1628
|
|
1632
|
1629
|
test 'primary_key';
|
1633
|
1630
|
use MyDBI1;
|
1634
|
|
-$dbi = MyDBI1->connect(%memory);
|
|
1631
|
+$dbi = MyDBI1->connect;
|
1635
|
1632
|
$model = $dbi->model('book');
|
1636
|
1633
|
$model->primary_key(['id', 'number']);
|
1637
|
1634
|
is_deeply($model->primary_key, ['id', 'number']);
|
1638
|
1635
|
|
1639
|
1636
|
test 'columns';
|
1640
|
1637
|
use MyDBI1;
|
1641
|
|
-$dbi = MyDBI1->connect(%memory);
|
|
1638
|
+$dbi = MyDBI1->connect;
|
1642
|
1639
|
$model = $dbi->model('book');
|
1643
|
1640
|
$model->columns(['id', 'number']);
|
1644
|
1641
|
is_deeply($model->columns, ['id', 'number']);
|
1645
|
1642
|
|
1646
|
1643
|
test 'setup_model';
|
1647
|
1644
|
use MyDBI1;
|
1648
|
|
-$dbi = MyDBI1->connect(%memory);
|
|
1645
|
+$dbi = MyDBI1->connect;
|
1649
|
1646
|
$dbi->execute('create table book (id)');
|
1650
|
1647
|
$dbi->execute('create table company (id, name);');
|
1651
|
1648
|
$dbi->execute('create table test (id, name, primary key (id, name));');
|
...
|
...
|
@@ -1654,7 +1651,7 @@ is_deeply($dbi->model('book')->columns, ['id']);
|
1654
|
1651
|
is_deeply($dbi->model('company')->columns, ['id', 'name']);
|
1655
|
1652
|
|
1656
|
1653
|
test 'delete_at';
|
1657
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1654
|
+$dbi = DBIx::Custom->connect;
|
1658
|
1655
|
$dbi->execute($create_table1_2);
|
1659
|
1656
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
1660
|
1657
|
$dbi->delete_at(
|
...
|
...
|
@@ -1673,7 +1670,7 @@ $dbi->delete_at(
|
1673
|
1670
|
is_deeply($dbi->select(table => 'table1')->all, []);
|
1674
|
1671
|
|
1675
|
1672
|
test 'insert_at';
|
1676
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1673
|
+$dbi = DBIx::Custom->connect;
|
1677
|
1674
|
$dbi->execute($create_table1_2);
|
1678
|
1675
|
$dbi->insert_at(
|
1679
|
1676
|
primary_key => ['key1', 'key2'],
|
...
|
...
|
@@ -1708,7 +1705,7 @@ eval {
|
1708
|
1705
|
};
|
1709
|
1706
|
like($@, qr/must be/);
|
1710
|
1707
|
|
1711
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1708
|
+$dbi = DBIx::Custom->connect;
|
1712
|
1709
|
$dbi->execute($create_table1_2);
|
1713
|
1710
|
$dbi->insert_at(
|
1714
|
1711
|
{key3 => 3},
|
...
|
...
|
@@ -1721,7 +1718,7 @@ is($dbi->select(table => 'table1')->one->{key2}, 2);
|
1721
|
1718
|
is($dbi->select(table => 'table1')->one->{key3}, 3);
|
1722
|
1719
|
|
1723
|
1720
|
test 'update_at';
|
1724
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1721
|
+$dbi = DBIx::Custom->connect;
|
1725
|
1722
|
$dbi->execute($create_table1_2);
|
1726
|
1723
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
1727
|
1724
|
$dbi->update_at(
|
...
|
...
|
@@ -1746,7 +1743,7 @@ is($dbi->select(table => 'table1')->one->{key1}, 1);
|
1746
|
1743
|
is($dbi->select(table => 'table1')->one->{key2}, 2);
|
1747
|
1744
|
is($dbi->select(table => 'table1')->one->{key3}, 4);
|
1748
|
1745
|
|
1749
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1746
|
+$dbi = DBIx::Custom->connect;
|
1750
|
1747
|
$dbi->execute($create_table1_2);
|
1751
|
1748
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
1752
|
1749
|
$dbi->update_at(
|
...
|
...
|
@@ -1760,7 +1757,7 @@ is($dbi->select(table => 'table1')->one->{key2}, 2);
|
1760
|
1757
|
is($dbi->select(table => 'table1')->one->{key3}, 4);
|
1761
|
1758
|
|
1762
|
1759
|
test 'select_at';
|
1763
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1760
|
+$dbi = DBIx::Custom->connect;
|
1764
|
1761
|
$dbi->execute($create_table1_2);
|
1765
|
1762
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
1766
|
1763
|
$result = $dbi->select_at(
|
...
|
...
|
@@ -1836,7 +1833,7 @@ like($@, qr/must be/);
|
1836
|
1833
|
|
1837
|
1834
|
test 'columns';
|
1838
|
1835
|
use MyDBI1;
|
1839
|
|
-$dbi = MyDBI1->connect(%memory);
|
|
1836
|
+$dbi = MyDBI1->connect;
|
1840
|
1837
|
$model = $dbi->model('book');
|
1841
|
1838
|
|
1842
|
1839
|
|
...
|
...
|
@@ -1854,7 +1851,7 @@ test 'model delete_at';
|
1854
|
1851
|
return $self;
|
1855
|
1852
|
}
|
1856
|
1853
|
}
|
1857
|
|
-$dbi = MyDBI6->connect(%memory);
|
|
1854
|
+$dbi = MyDBI6->connect;
|
1858
|
1855
|
$dbi->execute($create_table1_2);
|
1859
|
1856
|
$dbi->execute("create table table2 (key1, key2, key3)");
|
1860
|
1857
|
$dbi->execute("create table table3 (key1, key2, key3)");
|
...
|
...
|
@@ -1869,7 +1866,7 @@ $dbi->model('table1_3')->delete_at(where => [1, 2]);
|
1869
|
1866
|
is_deeply($dbi->select(table => 'table1')->all, []);
|
1870
|
1867
|
|
1871
|
1868
|
test 'model insert_at';
|
1872
|
|
-$dbi = MyDBI6->connect(%memory);
|
|
1869
|
+$dbi = MyDBI6->connect;
|
1873
|
1870
|
$dbi->execute($create_table1_2);
|
1874
|
1871
|
$dbi->model('table1')->insert_at(
|
1875
|
1872
|
where => [1, 2],
|
...
|
...
|
@@ -1882,7 +1879,7 @@ is($row->{key2}, 2);
|
1882
|
1879
|
is($row->{key3}, 3);
|
1883
|
1880
|
|
1884
|
1881
|
test 'model update_at';
|
1885
|
|
-$dbi = MyDBI6->connect(%memory);
|
|
1882
|
+$dbi = MyDBI6->connect;
|
1886
|
1883
|
$dbi->execute($create_table1_2);
|
1887
|
1884
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
1888
|
1885
|
$dbi->model('table1')->update_at(
|
...
|
...
|
@@ -1896,7 +1893,7 @@ is($row->{key2}, 2);
|
1896
|
1893
|
is($row->{key3}, 4);
|
1897
|
1894
|
|
1898
|
1895
|
test 'model select_at';
|
1899
|
|
-$dbi = MyDBI6->connect(%memory);
|
|
1896
|
+$dbi = MyDBI6->connect;
|
1900
|
1897
|
$dbi->execute($create_table1_2);
|
1901
|
1898
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
1902
|
1899
|
$result = $dbi->model('table1')->select_at(where => [1, 2]);
|
...
|
...
|
@@ -1921,7 +1918,7 @@ test 'mycolumn and column';
|
1921
|
1918
|
return $self;
|
1922
|
1919
|
}
|
1923
|
1920
|
}
|
1924
|
|
-$dbi = MyDBI7->connect(%memory);
|
|
1921
|
+$dbi = MyDBI7->connect;
|
1925
|
1922
|
$dbi->execute($create_table1);
|
1926
|
1923
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
1927
|
1924
|
$dbi->separator('__');
|
...
|
...
|
@@ -1937,7 +1934,7 @@ is_deeply($result->one,
|
1937
|
1934
|
{key1 => 1, key2 => 2, 'table2__key1' => 1, 'table2__key3' => 3});
|
1938
|
1935
|
|
1939
|
1936
|
test 'update_param';
|
1940
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1937
|
+$dbi = DBIx::Custom->connect;
|
1941
|
1938
|
$dbi->execute($create_table1_2);
|
1942
|
1939
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
1943
|
1940
|
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
...
|
...
|
@@ -1956,7 +1953,7 @@ is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
|
1956
|
1953
|
"basic");
|
1957
|
1954
|
|
1958
|
1955
|
|
1959
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1956
|
+$dbi = DBIx::Custom->connect;
|
1960
|
1957
|
$dbi->execute($create_table1_2);
|
1961
|
1958
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
1962
|
1959
|
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
...
|
...
|
@@ -1974,7 +1971,7 @@ is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 33, key4 => 4, key5 => 5},
|
1974
|
1971
|
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}],
|
1975
|
1972
|
"basic");
|
1976
|
1973
|
|
1977
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1974
|
+$dbi = DBIx::Custom->connect;
|
1978
|
1975
|
$dbi->execute($create_table1_2);
|
1979
|
1976
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
1980
|
1977
|
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
...
|
...
|
@@ -1998,7 +1995,7 @@ like($@, qr/not safety/);
|
1998
|
1995
|
|
1999
|
1996
|
|
2000
|
1997
|
test 'update_param';
|
2001
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
1998
|
+$dbi = DBIx::Custom->connect;
|
2002
|
1999
|
$dbi->execute($create_table1_2);
|
2003
|
2000
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
2004
|
2001
|
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
...
|
...
|
@@ -2018,7 +2015,7 @@ is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
|
2018
|
2015
|
|
2019
|
2016
|
|
2020
|
2017
|
test 'insert_param';
|
2021
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2018
|
+$dbi = DBIx::Custom->connect;
|
2022
|
2019
|
$dbi->execute($create_table1_2);
|
2023
|
2020
|
$param = {key1 => 1, key2 => 2};
|
2024
|
2021
|
$insert_param = $dbi->insert_param($param);
|
...
|
...
|
@@ -2029,7 +2026,7 @@ $dbi->execute($sql, param => $param, table => 'table1');
|
2029
|
2026
|
is($dbi->select(table => 'table1')->one->{key1}, 1);
|
2030
|
2027
|
is($dbi->select(table => 'table1')->one->{key2}, 2);
|
2031
|
2028
|
|
2032
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2029
|
+$dbi = DBIx::Custom->connect;
|
2033
|
2030
|
$dbi->quote('"');
|
2034
|
2031
|
$dbi->execute($create_table1_2);
|
2035
|
2032
|
$param = {key1 => 1, key2 => 2};
|
...
|
...
|
@@ -2046,7 +2043,7 @@ like($@, qr/not safety/);
|
2046
|
2043
|
|
2047
|
2044
|
|
2048
|
2045
|
test 'join';
|
2049
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2046
|
+$dbi = DBIx::Custom->connect;
|
2050
|
2047
|
$dbi->execute($create_table1);
|
2051
|
2048
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2052
|
2049
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
...
|
...
|
@@ -2105,7 +2102,7 @@ $rows = $dbi->select(
|
2105
|
2102
|
)->all;
|
2106
|
2103
|
is_deeply($rows, [{table1__key1 => 1}]);
|
2107
|
2104
|
|
2108
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2105
|
+$dbi = DBIx::Custom->connect;
|
2109
|
2106
|
$dbi->quote('"');
|
2110
|
2107
|
$dbi->execute($create_table1);
|
2111
|
2108
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
...
|
...
|
@@ -2134,7 +2131,7 @@ is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}],
|
2134
|
2131
|
}
|
2135
|
2132
|
}
|
2136
|
2133
|
|
2137
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2134
|
+$dbi = DBIx::Custom->connect;
|
2138
|
2135
|
$dbi->execute($create_table1);
|
2139
|
2136
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2140
|
2137
|
$sql = <<"EOS";
|
...
|
...
|
@@ -2154,7 +2151,7 @@ $rows = $dbi->select(
|
2154
|
2151
|
)->all;
|
2155
|
2152
|
is_deeply($rows, [{latest_table1__key1 => 1}]);
|
2156
|
2153
|
|
2157
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2154
|
+$dbi = DBIx::Custom->connect;
|
2158
|
2155
|
$dbi->execute($create_table1);
|
2159
|
2156
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2160
|
2157
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
...
|
...
|
@@ -2184,7 +2181,7 @@ $result = $dbi->select(
|
2184
|
2181
|
);
|
2185
|
2182
|
is_deeply($result->all, [{'table2.key3' => 4}]);
|
2186
|
2183
|
|
2187
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2184
|
+$dbi = DBIx::Custom->connect;
|
2188
|
2185
|
$dbi->execute($create_table1);
|
2189
|
2186
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2190
|
2187
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
...
|
...
|
@@ -2203,7 +2200,7 @@ $result = $dbi->select(
|
2203
|
2200
|
is_deeply($result->all, [{'table2.key3' => 4}]);
|
2204
|
2201
|
|
2205
|
2202
|
test 'mycolumn';
|
2206
|
|
-$dbi = MyDBI8->connect(%memory);
|
|
2203
|
+$dbi = MyDBI8->connect;
|
2207
|
2204
|
$dbi->execute($create_table1);
|
2208
|
2205
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2209
|
2206
|
$dbi->setup_model;
|
...
|
...
|
@@ -2268,14 +2265,14 @@ test 'dbi method from model';
|
2268
|
2265
|
return $self;
|
2269
|
2266
|
}
|
2270
|
2267
|
}
|
2271
|
|
-$dbi = MyDBI9->connect(%memory);
|
|
2268
|
+$dbi = MyDBI9->connect;
|
2272
|
2269
|
$dbi->execute($create_table1);
|
2273
|
2270
|
$model = $dbi->model('table1');
|
2274
|
2271
|
eval{$model->execute('select * from table1')};
|
2275
|
2272
|
ok(!$@);
|
2276
|
2273
|
|
2277
|
2274
|
test 'column table option';
|
2278
|
|
-$dbi = MyDBI9->connect(%memory);
|
|
2275
|
+$dbi = MyDBI9->connect;
|
2279
|
2276
|
$dbi->execute($create_table1);
|
2280
|
2277
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2281
|
2278
|
$dbi->setup_model;
|
...
|
...
|
@@ -2381,7 +2378,7 @@ $row = $result->one;
|
2381
|
2378
|
is($row->{key1_length}, length $binary);
|
2382
|
2379
|
|
2383
|
2380
|
test 'create_model';
|
2384
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2381
|
+$dbi = DBIx::Custom->connect;
|
2385
|
2382
|
$dbi->execute($create_table1);
|
2386
|
2383
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2387
|
2384
|
|
...
|
...
|
@@ -2415,7 +2412,7 @@ is_deeply($model2->select->one, {key1 => 1, key3 => 3});
|
2415
|
2412
|
|
2416
|
2413
|
test 'model method';
|
2417
|
2414
|
test 'create_model';
|
2418
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2415
|
+$dbi = DBIx::Custom->connect;
|
2419
|
2416
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2420
|
2417
|
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
|
2421
|
2418
|
$model = $dbi->create_model(
|
...
|
...
|
@@ -2442,7 +2439,7 @@ $param = $dbi->merge_param($params->[0], $params->[1]);
|
2442
|
2439
|
is_deeply($param, {key1 => [1, 2, 3, 4], key2 => [1, 2, 3], key3 => [1, 2, 3]});
|
2443
|
2440
|
|
2444
|
2441
|
test 'select() param option';
|
2445
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2442
|
+$dbi = DBIx::Custom->connect;
|
2446
|
2443
|
$dbi->execute($create_table1);
|
2447
|
2444
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2448
|
2445
|
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
|
...
|
...
|
@@ -2461,7 +2458,7 @@ is_deeply($rows, [{table1_key1 => 2, key2 => 3, key3 => 5}]);
|
2461
|
2458
|
|
2462
|
2459
|
|
2463
|
2460
|
test 'select() wrap option';
|
2464
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2461
|
+$dbi = DBIx::Custom->connect;
|
2465
|
2462
|
$dbi->execute($create_table1);
|
2466
|
2463
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2467
|
2464
|
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
|
...
|
...
|
@@ -2482,7 +2479,7 @@ $dbi->select(
|
2482
|
2479
|
like($@, qr/array/);
|
2483
|
2480
|
|
2484
|
2481
|
test 'select() string where';
|
2485
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2482
|
+$dbi = DBIx::Custom->connect;
|
2486
|
2483
|
$dbi->execute($create_table1);
|
2487
|
2484
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2488
|
2485
|
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
|
...
|
...
|
@@ -2493,7 +2490,7 @@ $rows = $dbi->select(
|
2493
|
2490
|
)->all;
|
2494
|
2491
|
is_deeply($rows, [{key1 => 1, key2 => 2}]);
|
2495
|
2492
|
|
2496
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2493
|
+$dbi = DBIx::Custom->connect;
|
2497
|
2494
|
$dbi->execute($create_table1);
|
2498
|
2495
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2499
|
2496
|
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
|
...
|
...
|
@@ -2507,7 +2504,7 @@ $rows = $dbi->select(
|
2507
|
2504
|
is_deeply($rows, [{key1 => 1, key2 => 2}]);
|
2508
|
2505
|
|
2509
|
2506
|
test 'delete() string where';
|
2510
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2507
|
+$dbi = DBIx::Custom->connect;
|
2511
|
2508
|
$dbi->execute($create_table1);
|
2512
|
2509
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2513
|
2510
|
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
|
...
|
...
|
@@ -2519,7 +2516,7 @@ $dbi->delete(
|
2519
|
2516
|
$rows = $dbi->select(table => 'table1')->all;
|
2520
|
2517
|
is_deeply($rows, [{key1 => 2, key2 => 3}]);
|
2521
|
2518
|
|
2522
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2519
|
+$dbi = DBIx::Custom->connect;
|
2523
|
2520
|
$dbi->execute($create_table1);
|
2524
|
2521
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2525
|
2522
|
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
|
...
|
...
|
@@ -2535,7 +2532,7 @@ is_deeply($rows, [{key1 => 2, key2 => 3}]);
|
2535
|
2532
|
|
2536
|
2533
|
|
2537
|
2534
|
test 'update() string where';
|
2538
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2535
|
+$dbi = DBIx::Custom->connect;
|
2539
|
2536
|
$dbi->execute($create_table1);
|
2540
|
2537
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2541
|
2538
|
$dbi->update(
|
...
|
...
|
@@ -2547,7 +2544,7 @@ $dbi->update(
|
2547
|
2544
|
$rows = $dbi->select(table => 'table1')->all;
|
2548
|
2545
|
is_deeply($rows, [{key1 => 5, key2 => 2}]);
|
2549
|
2546
|
|
2550
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2547
|
+$dbi = DBIx::Custom->connect;
|
2551
|
2548
|
$dbi->execute($create_table1);
|
2552
|
2549
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2553
|
2550
|
$dbi->update(
|
...
|
...
|
@@ -2562,7 +2559,7 @@ $rows = $dbi->select(table => 'table1')->all;
|
2562
|
2559
|
is_deeply($rows, [{key1 => 5, key2 => 2}]);
|
2563
|
2560
|
|
2564
|
2561
|
test 'insert id and primary_key option';
|
2565
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2562
|
+$dbi = DBIx::Custom->connect;
|
2566
|
2563
|
$dbi->execute($create_table1_2);
|
2567
|
2564
|
$dbi->insert(
|
2568
|
2565
|
primary_key => ['key1', 'key2'],
|
...
|
...
|
@@ -2586,7 +2583,7 @@ is($dbi->select(table => 'table1')->one->{key1}, 0);
|
2586
|
2583
|
is($dbi->select(table => 'table1')->one->{key2}, 2);
|
2587
|
2584
|
is($dbi->select(table => 'table1')->one->{key3}, 3);
|
2588
|
2585
|
|
2589
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2586
|
+$dbi = DBIx::Custom->connect;
|
2590
|
2587
|
$dbi->execute($create_table1_2);
|
2591
|
2588
|
$dbi->insert(
|
2592
|
2589
|
{key3 => 3},
|
...
|
...
|
@@ -2600,7 +2597,7 @@ is($dbi->select(table => 'table1')->one->{key3}, 3);
|
2600
|
2597
|
|
2601
|
2598
|
|
2602
|
2599
|
test 'model insert id and primary_key option';
|
2603
|
|
-$dbi = MyDBI6->connect(%memory);
|
|
2600
|
+$dbi = MyDBI6->connect;
|
2604
|
2601
|
$dbi->execute($create_table1_2);
|
2605
|
2602
|
$dbi->model('table1')->insert(
|
2606
|
2603
|
id => [1, 2],
|
...
|
...
|
@@ -2612,7 +2609,7 @@ is($row->{key1}, 1);
|
2612
|
2609
|
is($row->{key2}, 2);
|
2613
|
2610
|
is($row->{key3}, 3);
|
2614
|
2611
|
|
2615
|
|
-$dbi = MyDBI6->connect(%memory);
|
|
2612
|
+$dbi = MyDBI6->connect;
|
2616
|
2613
|
$dbi->execute($create_table1_2);
|
2617
|
2614
|
$dbi->model('table1')->insert(
|
2618
|
2615
|
{key3 => 3},
|
...
|
...
|
@@ -2625,7 +2622,7 @@ is($row->{key2}, 2);
|
2625
|
2622
|
is($row->{key3}, 3);
|
2626
|
2623
|
|
2627
|
2624
|
test 'update and id option';
|
2628
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2625
|
+$dbi = DBIx::Custom->connect;
|
2629
|
2626
|
$dbi->execute($create_table1_2);
|
2630
|
2627
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
2631
|
2628
|
$dbi->update(
|
...
|
...
|
@@ -2650,7 +2647,7 @@ is($dbi->select(table => 'table1')->one->{key1}, 0);
|
2650
|
2647
|
is($dbi->select(table => 'table1')->one->{key2}, 2);
|
2651
|
2648
|
is($dbi->select(table => 'table1')->one->{key3}, 4);
|
2652
|
2649
|
|
2653
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2650
|
+$dbi = DBIx::Custom->connect;
|
2654
|
2651
|
$dbi->execute($create_table1_2);
|
2655
|
2652
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
2656
|
2653
|
$dbi->update(
|
...
|
...
|
@@ -2665,7 +2662,7 @@ is($dbi->select(table => 'table1')->one->{key3}, 4);
|
2665
|
2662
|
|
2666
|
2663
|
|
2667
|
2664
|
test 'model update and id option';
|
2668
|
|
-$dbi = MyDBI6->connect(%memory);
|
|
2665
|
+$dbi = MyDBI6->connect;
|
2669
|
2666
|
$dbi->execute($create_table1_2);
|
2670
|
2667
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
2671
|
2668
|
$dbi->model('table1')->update(
|
...
|
...
|
@@ -2680,7 +2677,7 @@ is($row->{key3}, 4);
|
2680
|
2677
|
|
2681
|
2678
|
|
2682
|
2679
|
test 'delete and id option';
|
2683
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2680
|
+$dbi = DBIx::Custom->connect;
|
2684
|
2681
|
$dbi->execute($create_table1_2);
|
2685
|
2682
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
2686
|
2683
|
$dbi->delete(
|
...
|
...
|
@@ -2700,7 +2697,7 @@ is_deeply($dbi->select(table => 'table1')->all, []);
|
2700
|
2697
|
|
2701
|
2698
|
|
2702
|
2699
|
test 'model delete and id option';
|
2703
|
|
-$dbi = MyDBI6->connect(%memory);
|
|
2700
|
+$dbi = MyDBI6->connect;
|
2704
|
2701
|
$dbi->execute($create_table1_2);
|
2705
|
2702
|
$dbi->execute("create table table2 (key1, key2, key3)");
|
2706
|
2703
|
$dbi->execute("create table table3 (key1, key2, key3)");
|
...
|
...
|
@@ -2716,7 +2713,7 @@ is_deeply($dbi->select(table => 'table1')->all, []);
|
2716
|
2713
|
|
2717
|
2714
|
|
2718
|
2715
|
test 'select and id option';
|
2719
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2716
|
+$dbi = DBIx::Custom->connect;
|
2720
|
2717
|
$dbi->execute($create_table1_2);
|
2721
|
2718
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
2722
|
2719
|
$result = $dbi->select(
|
...
|
...
|
@@ -2755,7 +2752,7 @@ is($row->{key3}, 3);
|
2755
|
2752
|
|
2756
|
2753
|
|
2757
|
2754
|
test 'model select_at';
|
2758
|
|
-$dbi = MyDBI6->connect(%memory);
|
|
2755
|
+$dbi = MyDBI6->connect;
|
2759
|
2756
|
$dbi->execute($create_table1_2);
|
2760
|
2757
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
2761
|
2758
|
$result = $dbi->model('table1')->select(id => [1, 2]);
|
...
|
...
|
@@ -2765,7 +2762,7 @@ is($row->{key2}, 2);
|
2765
|
2762
|
is($row->{key3}, 3);
|
2766
|
2763
|
|
2767
|
2764
|
test 'column separator is default .';
|
2768
|
|
-$dbi = MyDBI7->connect(%memory);
|
|
2765
|
+$dbi = MyDBI7->connect;
|
2769
|
2766
|
$dbi->execute($create_table1);
|
2770
|
2767
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2771
|
2768
|
$dbi->setup_model;
|
...
|
...
|
@@ -2788,7 +2785,7 @@ is_deeply($result->one,
|
2788
|
2785
|
|
2789
|
2786
|
|
2790
|
2787
|
test 'type_rule from';
|
2791
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2788
|
+$dbi = DBIx::Custom->connect;
|
2792
|
2789
|
$dbi->type_rule(
|
2793
|
2790
|
from1 => {
|
2794
|
2791
|
date => sub { uc $_[0] }
|
...
|
...
|
@@ -2804,7 +2801,7 @@ is($result->one->{key1}, 'A');
|
2804
|
2801
|
|
2805
|
2802
|
|
2806
|
2803
|
test 'type_rule into';
|
2807
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2804
|
+$dbi = DBIx::Custom->connect;
|
2808
|
2805
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2809
|
2806
|
$dbi->type_rule(
|
2810
|
2807
|
into1 => {
|
...
|
...
|
@@ -2815,7 +2812,7 @@ $dbi->insert({key1 => 'a'}, table => 'table1');
|
2815
|
2812
|
$result = $dbi->select(table => 'table1');
|
2816
|
2813
|
is($result->one->{key1}, 'A');
|
2817
|
2814
|
|
2818
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2815
|
+$dbi = DBIx::Custom->connect;
|
2819
|
2816
|
$dbi->execute("create table table1 (key1 date, key2 datetime)");
|
2820
|
2817
|
$dbi->type_rule(
|
2821
|
2818
|
into1 => [
|
...
|
...
|
@@ -2828,7 +2825,7 @@ $row = $result->one;
|
2828
|
2825
|
is($row->{key1}, 'A');
|
2829
|
2826
|
is($row->{key2}, 'B');
|
2830
|
2827
|
|
2831
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2828
|
+$dbi = DBIx::Custom->connect;
|
2832
|
2829
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2833
|
2830
|
$dbi->insert({key1 => 'a', key2 => 'B'}, table => 'table1');
|
2834
|
2831
|
$dbi->type_rule(
|
...
|
...
|
@@ -2844,7 +2841,7 @@ $row = $result->one;
|
2844
|
2841
|
is($row->{key1}, 'a');
|
2845
|
2842
|
is($row->{key2}, 'B');
|
2846
|
2843
|
|
2847
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2844
|
+$dbi = DBIx::Custom->connect;
|
2848
|
2845
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2849
|
2846
|
$dbi->insert({key1 => 'A', key2 => 'B'}, table => 'table1');
|
2850
|
2847
|
$dbi->type_rule(
|
...
|
...
|
@@ -2861,7 +2858,7 @@ $row = $result->one;
|
2861
|
2858
|
is($row->{key1}, 'A');
|
2862
|
2859
|
is($row->{key2}, 'B');
|
2863
|
2860
|
|
2864
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2861
|
+$dbi = DBIx::Custom->connect;
|
2865
|
2862
|
$dbi->execute("create table table1 (key1 date, key2 datetime)");
|
2866
|
2863
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
2867
|
2864
|
$dbi->type_rule(
|
...
|
...
|
@@ -2877,7 +2874,7 @@ $result = $dbi->select(table => 'table1');
|
2877
|
2874
|
is($result->fetch->[0], 8);
|
2878
|
2875
|
|
2879
|
2876
|
test 'type_rule and filter order';
|
2880
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2877
|
+$dbi = DBIx::Custom->connect;
|
2881
|
2878
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2882
|
2879
|
$dbi->type_rule(
|
2883
|
2880
|
into1 => {
|
...
|
...
|
@@ -2898,7 +2895,7 @@ $result = $dbi->select(table => 'table1');
|
2898
|
2895
|
$result->filter(key1 => sub { $_[0] . 'f' });
|
2899
|
2896
|
is($result->fetch_first->[0], '1abcdef');
|
2900
|
2897
|
|
2901
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2898
|
+$dbi = DBIx::Custom->connect;
|
2902
|
2899
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2903
|
2900
|
$dbi->type_rule(
|
2904
|
2901
|
from1 => {
|
...
|
...
|
@@ -2922,7 +2919,7 @@ $result->filter(key1 => sub { $_[0] . 'f' });
|
2922
|
2919
|
is($result->fetch_first->[0], '1def');
|
2923
|
2920
|
|
2924
|
2921
|
test 'type_rule_off';
|
2925
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2922
|
+$dbi = DBIx::Custom->connect;
|
2926
|
2923
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2927
|
2924
|
$dbi->type_rule(
|
2928
|
2925
|
from1 => {
|
...
|
...
|
@@ -2936,7 +2933,7 @@ $dbi->insert({key1 => 2}, table => 'table1', type_rule_off => 1);
|
2936
|
2933
|
$result = $dbi->select(table => 'table1', type_rule_off => 1);
|
2937
|
2934
|
is($result->type_rule_off->fetch->[0], 2);
|
2938
|
2935
|
|
2939
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2936
|
+$dbi = DBIx::Custom->connect;
|
2940
|
2937
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2941
|
2938
|
$dbi->type_rule(
|
2942
|
2939
|
from1 => {
|
...
|
...
|
@@ -2950,7 +2947,7 @@ $dbi->insert({key1 => 2}, table => 'table1', type_rule_off => 1);
|
2950
|
2947
|
$result = $dbi->select(table => 'table1', type_rule_off => 1);
|
2951
|
2948
|
is($result->one->{key1}, 4);
|
2952
|
2949
|
|
2953
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2950
|
+$dbi = DBIx::Custom->connect;
|
2954
|
2951
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2955
|
2952
|
$dbi->type_rule(
|
2956
|
2953
|
from1 => {
|
...
|
...
|
@@ -2964,7 +2961,7 @@ $dbi->insert({key1 => 2}, table => 'table1');
|
2964
|
2961
|
$result = $dbi->select(table => 'table1');
|
2965
|
2962
|
is($result->one->{key1}, 12);
|
2966
|
2963
|
|
2967
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2964
|
+$dbi = DBIx::Custom->connect;
|
2968
|
2965
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2969
|
2966
|
$dbi->type_rule(
|
2970
|
2967
|
from1 => {
|
...
|
...
|
@@ -2978,7 +2975,7 @@ $dbi->insert({key1 => 2}, table => 'table1');
|
2978
|
2975
|
$result = $dbi->select(table => 'table1');
|
2979
|
2976
|
is($result->fetch->[0], 12);
|
2980
|
2977
|
|
2981
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2978
|
+$dbi = DBIx::Custom->connect;
|
2982
|
2979
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2983
|
2980
|
$dbi->register_filter(ppp => sub { uc $_[0] });
|
2984
|
2981
|
$dbi->type_rule(
|
...
|
...
|
@@ -2997,7 +2994,7 @@ eval{$dbi->type_rule(
|
2997
|
2994
|
)};
|
2998
|
2995
|
like($@, qr/not registered/);
|
2999
|
2996
|
|
3000
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
2997
|
+$dbi = DBIx::Custom->connect;
|
3001
|
2998
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3002
|
2999
|
eval {
|
3003
|
3000
|
$dbi->type_rule(
|
...
|
...
|
@@ -3017,7 +3014,7 @@ eval {
|
3017
|
3014
|
};
|
3018
|
3015
|
like($@, qr/lower/);
|
3019
|
3016
|
|
3020
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3017
|
+$dbi = DBIx::Custom->connect;
|
3021
|
3018
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3022
|
3019
|
$dbi->type_rule(
|
3023
|
3020
|
from1 => {
|
...
|
...
|
@@ -3032,7 +3029,7 @@ $result = $dbi->select(table => 'table1');
|
3032
|
3029
|
$result->type_rule_off;
|
3033
|
3030
|
is($result->one->{key1}, 6);
|
3034
|
3031
|
|
3035
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3032
|
+$dbi = DBIx::Custom->connect;
|
3036
|
3033
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3037
|
3034
|
$dbi->type_rule(
|
3038
|
3035
|
from1 => {
|
...
|
...
|
@@ -3093,7 +3090,7 @@ $row = $result->one;
|
3093
|
3090
|
is($row->{key1}, 2);
|
3094
|
3091
|
is($row->{key2}, 2);
|
3095
|
3092
|
|
3096
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3093
|
+$dbi = DBIx::Custom->connect;
|
3097
|
3094
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3098
|
3095
|
$dbi->type_rule(
|
3099
|
3096
|
from1 => {
|
...
|
...
|
@@ -3105,7 +3102,7 @@ $result = $dbi->select(table => 'table1');
|
3105
|
3102
|
$result->filter(key1 => sub { $_[0] * 3 });
|
3106
|
3103
|
is($result->one->{key1}, 12);
|
3107
|
3104
|
|
3108
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3105
|
+$dbi = DBIx::Custom->connect;
|
3109
|
3106
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3110
|
3107
|
$dbi->type_rule(
|
3111
|
3108
|
from1 => {
|
...
|
...
|
@@ -3117,7 +3114,7 @@ $result = $dbi->select(table => 'table1');
|
3117
|
3114
|
$result->filter(key1 => sub { $_[0] * 3 });
|
3118
|
3115
|
is($result->fetch->[0], 12);
|
3119
|
3116
|
|
3120
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3117
|
+$dbi = DBIx::Custom->connect;
|
3121
|
3118
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3122
|
3119
|
$dbi->type_rule(
|
3123
|
3120
|
into1 => {
|
...
|
...
|
@@ -3139,7 +3136,7 @@ is($result->type_rule_off->fetch_first->[0], '1');
|
3139
|
3136
|
$result = $dbi->select(table => 'table1');
|
3140
|
3137
|
is($result->type_rule_on->fetch_first->[0], '1de');
|
3141
|
3138
|
|
3142
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3139
|
+$dbi = DBIx::Custom->connect;
|
3143
|
3140
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3144
|
3141
|
$dbi->type_rule(
|
3145
|
3142
|
into1 => {
|
...
|
...
|
@@ -3161,7 +3158,7 @@ is($result->type_rule1_off->fetch_first->[0], '1ce');
|
3161
|
3158
|
$result = $dbi->select(table => 'table1');
|
3162
|
3159
|
is($result->type_rule1_on->fetch_first->[0], '1cde');
|
3163
|
3160
|
|
3164
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3161
|
+$dbi = DBIx::Custom->connect;
|
3165
|
3162
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3166
|
3163
|
$dbi->type_rule(
|
3167
|
3164
|
into1 => {
|
...
|
...
|
@@ -3184,7 +3181,7 @@ $result = $dbi->select(table => 'table1');
|
3184
|
3181
|
is($result->type_rule2_on->fetch_first->[0], '1bde');
|
3185
|
3182
|
|
3186
|
3183
|
test 'separator';
|
3187
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3184
|
+$dbi = DBIx::Custom->connect;
|
3188
|
3185
|
$dbi->execute($create_table1);
|
3189
|
3186
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
3190
|
3187
|
|
...
|
...
|
@@ -3241,7 +3238,7 @@ is_deeply($model2->select->one, {key1 => 1, key3 => 3});
|
3241
|
3238
|
|
3242
|
3239
|
|
3243
|
3240
|
test 'filter_off';
|
3244
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3241
|
+$dbi = DBIx::Custom->connect;
|
3245
|
3242
|
$dbi->execute($create_table1);
|
3246
|
3243
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
3247
|
3244
|
|
...
|
...
|
@@ -3260,12 +3257,12 @@ $result->filter(key1 => sub { $_[0] * 2 });
|
3260
|
3257
|
is_deeply($result->one, {key1 => 2});
|
3261
|
3258
|
|
3262
|
3259
|
test 'available_datetype';
|
3263
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3260
|
+$dbi = DBIx::Custom->connect;
|
3264
|
3261
|
ok($dbi->can('available_datatype'));
|
3265
|
3262
|
|
3266
|
3263
|
|
3267
|
3264
|
test 'select prefix option';
|
3268
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3265
|
+$dbi = DBIx::Custom->connect;
|
3269
|
3266
|
$dbi->execute($create_table1);
|
3270
|
3267
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
3271
|
3268
|
$rows = $dbi->select(prefix => 'key1,', column => 'key2', table => 'table1')->all;
|
...
|
...
|
@@ -3273,7 +3270,7 @@ is_deeply($rows, [{key1 => 1, key2 => 2}], "table");
|
3273
|
3270
|
|
3274
|
3271
|
|
3275
|
3272
|
test 'separator';
|
3276
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3273
|
+$dbi = DBIx::Custom->connect;
|
3277
|
3274
|
is($dbi->separator, '.');
|
3278
|
3275
|
$dbi->separator('-');
|
3279
|
3276
|
is($dbi->separator, '-');
|
...
|
...
|
@@ -3284,7 +3281,7 @@ like($@, qr/Separator/);
|
3284
|
3281
|
|
3285
|
3282
|
|
3286
|
3283
|
test 'map_param';
|
3287
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3284
|
+$dbi = DBIx::Custom->connect;
|
3288
|
3285
|
$param = $dbi->map_param(
|
3289
|
3286
|
{id => 1, author => 'Ken', price => 1900},
|
3290
|
3287
|
id => 'book.id',
|
...
|
...
|
@@ -3328,7 +3325,7 @@ is_deeply($param, {'book.price' => '%a'});
|
3328
|
3325
|
|
3329
|
3326
|
|
3330
|
3327
|
test 'table_alias';
|
3331
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3328
|
+$dbi = DBIx::Custom->connect;
|
3332
|
3329
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3333
|
3330
|
$dbi->type_rule(
|
3334
|
3331
|
into1 => {
|
...
|
...
|
@@ -3342,7 +3339,7 @@ is($result->one->{key1}, 'A');
|
3342
|
3339
|
|
3343
|
3340
|
|
3344
|
3341
|
test 'order';
|
3345
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3342
|
+$dbi = DBIx::Custom->connect;
|
3346
|
3343
|
$dbi->execute("create table table1 (key1, key2)");
|
3347
|
3344
|
$dbi->insert({key1 => 1, key2 => 1}, table => 'table1');
|
3348
|
3345
|
$dbi->insert({key1 => 1, key2 => 3}, table => 'table1');
|
...
|
...
|
@@ -3369,7 +3366,7 @@ is_deeply($result->all, [{'table1-key1' => 1, 'table1-key2' => 3},
|
3369
|
3366
|
{'table1-key1' => 2, 'table1-key2' => 2}]);
|
3370
|
3367
|
|
3371
|
3368
|
test 'tag_parse';
|
3372
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3369
|
+$dbi = DBIx::Custom->connect;
|
3373
|
3370
|
$dbi->tag_parse(0);
|
3374
|
3371
|
$dbi->execute("create table table1 (key1, key2)");
|
3375
|
3372
|
$dbi->insert({key1 => 1, key2 => 1}, table => 'table1');
|
...
|
...
|
@@ -3377,7 +3374,7 @@ eval {$dbi->execute("select * from table1 where {= key1}", {key1 => 1})};
|
3377
|
3374
|
ok($@);
|
3378
|
3375
|
|
3379
|
3376
|
test 'last_sql';
|
3380
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3377
|
+$dbi = DBIx::Custom->connect;
|
3381
|
3378
|
$dbi->execute("create table table1 (key1, key2)");
|
3382
|
3379
|
$dbi->execute('select * from table1');
|
3383
|
3380
|
is($dbi->last_sql, 'select * from table1;');
|
...
|
...
|
@@ -3386,7 +3383,7 @@ eval{$dbi->execute("aaa")};
|
3386
|
3383
|
is($dbi->last_sql, 'aaa;');
|
3387
|
3384
|
|
3388
|
3385
|
test 'DBIx::Custom header';
|
3389
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3386
|
+$dbi = DBIx::Custom->connect;
|
3390
|
3387
|
$dbi->execute("create table table1 (key1, key2)");
|
3391
|
3388
|
$result = $dbi->execute('select key1 as h1, key2 as h2 from table1');
|
3392
|
3389
|
is_deeply($result->header, [qw/h1 h2/]);
|
...
|
...
|
@@ -3465,7 +3462,7 @@ $rows = [
|
3465
|
3462
|
}
|
3466
|
3463
|
|
3467
|
3464
|
test 'result';
|
3468
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3465
|
+$dbi = DBIx::Custom->connect;
|
3469
|
3466
|
$dbi->execute($create_table1);
|
3470
|
3467
|
$dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
|
3471
|
3468
|
$dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
|
...
|
...
|
@@ -3501,7 +3498,7 @@ $result = $dbi->select(table => 'table2');
|
3501
|
3498
|
$row = $result->fetch_hash_first;
|
3502
|
3499
|
ok(!$row, "no row fetch");
|
3503
|
3500
|
|
3504
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3501
|
+$dbi = DBIx::Custom->connect;
|
3505
|
3502
|
$dbi->execute($create_table1);
|
3506
|
3503
|
$dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
|
3507
|
3504
|
$dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
|
...
|
...
|
@@ -3540,7 +3537,7 @@ $result = $dbi->select(table => 'table1');
|
3540
|
3537
|
eval {$result->fetch_hash_multi};
|
3541
|
3538
|
like($@, qr/Row count must be specified/, "Not specified row count");
|
3542
|
3539
|
|
3543
|
|
-$dbi = DBIx::Custom->connect(%memory);
|
|
3540
|
+$dbi = DBIx::Custom->connect;
|
3544
|
3541
|
$dbi->execute($create_table1);
|
3545
|
3542
|
$dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
|
3546
|
3543
|
$dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
|