Showing 1 changed files with 40 additions and 0 deletions
+40
t/sqlite.t
... ...
@@ -467,6 +467,7 @@ is($dbi->filters->{encode_utf8}->('あ'),
467 467
 
468 468
 test 'transaction';
469 469
 $dbi = DBIx::Custom->connect;
470
+eval { $dbi->execute('drop table table1') };
470 471
 $dbi->execute($create_table1);
471 472
 $dbi->dbh->begin_work;
472 473
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
... ...
@@ -477,6 +478,7 @@ is_deeply(scalar $result->all, [{key1 => 1, key2 => 2}, {key1 => 2, key2 => 3}],
477 478
           "commit");
478 479
 
479 480
 $dbi = DBIx::Custom->connect;
481
+eval { $dbi->execute('drop table table1') };
480 482
 $dbi->execute($create_table1);
481 483
 $dbi->dbh->begin_work(0);
482 484
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
... ...
@@ -538,6 +540,7 @@ ok($@, "execute fail");
538 540
 
539 541
 test 'transaction';
540 542
 $dbi = DBIx::Custom->connect;
543
+eval { $dbi->execute('drop table table1') };
541 544
 $dbi->execute($create_table1);
542 545
 
543 546
 $dbi->begin_work;
... ...
@@ -641,6 +644,7 @@ $row   = $result->one;
641 644
 is_deeply($row, {key1 => 4, key2 => 2}, "update");
642 645
 
643 646
 $dbi = DBIx::Custom->connect;
647
+eval { $dbi->execute('drop table table1') };
644 648
 $dbi->execute($create_table1);
645 649
 $dbi->register_filter(twice => sub { $_[0] * 2 });
646 650
 $dbi->apply_filter(
... ...
@@ -653,6 +657,7 @@ $rows   = $result->all;
653 657
 is_deeply($rows, [], "delete");
654 658
 
655 659
 $dbi = DBIx::Custom->connect;
660
+eval { $dbi->execute('drop table table1') };
656 661
 $dbi->execute($create_table1);
657 662
 $dbi->register_filter(twice => sub { $_[0] * 2 });
658 663
 $dbi->apply_filter(
... ...
@@ -665,6 +670,7 @@ $rows   = $result->all;
665 670
 is_deeply($rows, [{key1 => 4, key2 => 4}], "select");
666 671
 
667 672
 $dbi = DBIx::Custom->connect;
673
+eval { $dbi->execute('drop table table1') };
668 674
 $dbi->execute($create_table1);
669 675
 $dbi->register_filter(twice => sub { $_[0] * 2 });
670 676
 $dbi->apply_filter(
... ...
@@ -678,6 +684,7 @@ $rows   = $result->all;
678 684
 is_deeply($rows, [{key1 => 4, key2 => 2}], "execute");
679 685
 
680 686
 $dbi = DBIx::Custom->connect;
687
+eval { $dbi->execute('drop table table1') };
681 688
 $dbi->execute($create_table1);
682 689
 $dbi->register_filter(twice => sub { $_[0] * 2 });
683 690
 $dbi->apply_filter(
... ...
@@ -690,6 +697,7 @@ $rows   = $result->all;
690 697
 is_deeply($rows, [{key1 => 4, key2 => 2}], "execute table tag");
691 698
 
692 699
 $dbi = DBIx::Custom->connect;
700
+eval { $dbi->execute('drop table table1') };
693 701
 $dbi->execute($create_table1);
694 702
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
695 703
 $dbi->register_filter(twice => sub { $_[0] * 2 });
... ...
@@ -722,6 +730,8 @@ is_deeply($rows, [{key2 => 4, key3 => 18}], "select : join : omit");
722 730
 
723 731
 test 'each_column';
724 732
 $dbi = DBIx::Custom->connect;
733
+eval { $dbi->execute('drop table table1') };
734
+eval { $dbi->execute('drop table table2') };
725 735
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
726 736
 $dbi->execute('create table table1 (key1 Date, key2 datetime);');
727 737
 
... ...
@@ -746,6 +756,8 @@ is_deeply($infos,
746 756
 );
747 757
 test 'each_table';
748 758
 $dbi = DBIx::Custom->connect;
759
+eval { $dbi->execute('drop table table1') };
760
+eval { $dbi->execute('drop table table2') };
749 761
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
750 762
 $dbi->execute('create table table1 (key1 Date, key2 datetime);');
751 763
 
... ...
@@ -768,6 +780,7 @@ is_deeply($infos,
768 780
 
769 781
 test 'limit';
770 782
 $dbi = DBIx::Custom->connect;
783
+eval { $dbi->execute('drop table table1') };
771 784
 $dbi->execute($create_table1);
772 785
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
773 786
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 4});
... ...
@@ -821,12 +834,14 @@ test 'connect super';
821 834
 }
822 835
 
823 836
 $dbi = MyDBI->connect;
837
+eval { $dbi->execute('drop table table1') };
824 838
 $dbi->execute($create_table1);
825 839
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
826 840
 is($dbi->select(table => 'table1')->one->{key1}, 1);
827 841
 
828 842
 $dbi = MyDBI->new;
829 843
 $dbi->connect;
844
+eval { $dbi->execute('drop table table1') };
830 845
 $dbi->execute($create_table1);
831 846
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
832 847
 is($dbi->select(table => 'table1')->one->{key1}, 1);
... ...
@@ -844,12 +859,14 @@ is($dbi->select(table => 'table1')->one->{key1}, 1);
844 859
 }
845 860
 
846 861
 $dbi = MyDBI->connect;
862
+eval { $dbi->execute('drop table table1') };
847 863
 $dbi->execute($create_table1);
848 864
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
849 865
 is($dbi->select(table => 'table1')->one->{key1}, 1);
850 866
 
851 867
 test 'end_filter';
852 868
 $dbi = DBIx::Custom->connect;
869
+eval { $dbi->execute('drop table table1') };
853 870
 $dbi->execute($create_table1);
854 871
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
855 872
 $result = $dbi->select(table => 'table1');
... ...
@@ -859,6 +876,7 @@ $row = $result->fetch_first;
859 876
 is_deeply($row, [6, 40]);
860 877
 
861 878
 $dbi = DBIx::Custom->connect;
879
+eval { $dbi->execute('drop table table1') };
862 880
 $dbi->execute($create_table1);
863 881
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
864 882
 $result = $dbi->select(table => 'table1');
... ...
@@ -868,6 +886,7 @@ $row = $result->fetch_first;
868 886
 is_deeply($row, [6, 12]);
869 887
 
870 888
 $dbi = DBIx::Custom->connect;
889
+eval { $dbi->execute('drop table table1') };
871 890
 $dbi->execute($create_table1);
872 891
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
873 892
 $result = $dbi->select(table => 'table1');
... ...
@@ -907,6 +926,7 @@ is_deeply($row, {key1 => 1, key2 => 40}, 'apply_filter overwrite');
907 926
 
908 927
 test 'remove_end_filter and remove_filter';
909 928
 $dbi = DBIx::Custom->connect;
929
+eval { $dbi->execute('drop table table1') };
910 930
 $dbi->execute($create_table1);
911 931
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
912 932
 $result = $dbi->select(table => 'table1');
... ...
@@ -920,6 +940,7 @@ is_deeply($row, [1, 2]);
920 940
 
921 941
 test 'empty where select';
922 942
 $dbi = DBIx::Custom->connect;
943
+eval { $dbi->execute('drop table table1') };
923 944
 $dbi->execute($create_table1);
924 945
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
925 946
 $result = $dbi->select(table => 'table1', where => {});
... ...
@@ -928,6 +949,7 @@ is_deeply($row, {key1 => 1, key2 => 2});
928 949
 
929 950
 test 'select query option';
930 951
 $dbi = DBIx::Custom->connect;
952
+eval { $dbi->execute('drop table table1') };
931 953
 $dbi->execute($create_table1);
932 954
 $query = $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, query => 1);
933 955
 is(ref $query, 'DBIx::Custom::Query');
... ...
@@ -940,6 +962,7 @@ is(ref $query, 'DBIx::Custom::Query');
940 962
 
941 963
 test 'where';
942 964
 $dbi = DBIx::Custom->connect;
965
+eval { $dbi->execute('drop table table1') };
943 966
 $dbi->execute($create_table1);
944 967
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
945 968
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
... ...
@@ -1414,6 +1437,7 @@ $dbi->apply_filter(
1414 1437
 
1415 1438
 );
1416 1439
 $dbi = DBIx::Custom->connect;
1440
+eval { $dbi->execute('drop table table1') };
1417 1441
 $dbi->execute($create_table1);
1418 1442
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1419 1443
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
... ...
@@ -1423,6 +1447,7 @@ $rows = $dbi->select(table => 'table1', where => {key2 => 1})->all;
1423 1447
 is_deeply($rows, [{key1 => 1, key2 => 6}]);
1424 1448
 
1425 1449
 $dbi = DBIx::Custom->connect;
1450
+eval { $dbi->execute('drop table table1') };
1426 1451
 $dbi->execute($create_table1);
1427 1452
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1428 1453
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
... ...
@@ -1442,6 +1467,7 @@ eval{DBIx::Custom->connect(dsn => undef)};
1442 1467
 like($@, qr/_connect/);
1443 1468
 
1444 1469
 $dbi = DBIx::Custom->connect;
1470
+eval { $dbi->execute('drop table table1') };
1445 1471
 $dbi->execute($create_table1);
1446 1472
 $dbi->register_filter(twice => sub { $_[0] * 2 });
1447 1473
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2},
... ...
@@ -1469,6 +1495,7 @@ eval {$dbi->execute('select * from table1 {} {= author') };
1469 1495
 like($@, qr/Tag not finished/);
1470 1496
 
1471 1497
 $dbi = DBIx::Custom->connect;
1498
+eval { $dbi->execute('drop table table1') };
1472 1499
 $dbi->execute($create_table1);
1473 1500
 $dbi->register_filter(one => sub { 1 });
1474 1501
 $result = $dbi->select(table => 'table1');
... ...
@@ -1495,6 +1522,8 @@ is($result->stash->{foo}, 1, 'get and set');
1495 1522
 
1496 1523
 test 'filter __ expression';
1497 1524
 $dbi = DBIx::Custom->connect;
1525
+eval { $dbi->execute('drop table company') };
1526
+eval { $dbi->execute('drop table location') };
1498 1527
 $dbi->execute('create table company (id, name, location_id)');
1499 1528
 $dbi->execute('create table location (id, name)');
1500 1529
 $dbi->apply_filter('location',
... ...
@@ -1525,6 +1554,7 @@ is($result->fetch_first->[0], 'B');
1525 1554
 test 'Model class';
1526 1555
 use MyDBI1;
1527 1556
 $dbi = MyDBI1->connect;
1557
+eval { $dbi->execute('drop table book') };
1528 1558
 $dbi->execute("create table book (title, author)");
1529 1559
 $model = $dbi->model('book');
1530 1560
 $model->insert({title => 'a', author => 'b'});
... ...
@@ -1593,6 +1623,7 @@ is($dbi->models->{'company'}, $dbi->model('company'));
1593 1623
     sub list { shift->select; }
1594 1624
 }
1595 1625
 $dbi = MyDBI4->connect;
1626
+eval { $dbi->execute('drop table book') };
1596 1627
 $dbi->execute("create table book (title, author)");
1597 1628
 $model = $dbi->model('book');
1598 1629
 $model->insert({title => 'a', author => 'b'});
... ...
@@ -1617,6 +1648,8 @@ is_deeply($model->list->all, [{name => 'a'}], 'basic');
1617 1648
     }
1618 1649
 }
1619 1650
 $dbi = MyDBI5->connect;
1651
+eval { $dbi->execute('drop table company') };
1652
+eval { $dbi->execute('drop table table1') };
1620 1653
 $dbi->execute("create table company (name)");
1621 1654
 $dbi->execute("create table table1 (key1)");
1622 1655
 $model = $dbi->model('company');
... ...
@@ -1643,6 +1676,10 @@ is_deeply($model->columns, ['id', 'number']);
1643 1676
 test 'setup_model';
1644 1677
 use MyDBI1;
1645 1678
 $dbi = MyDBI1->connect;
1679
+eval { $dbi->execute('drop table book') };
1680
+eval { $dbi->execute('drop table company') };
1681
+eval { $dbi->execute('drop table test') };
1682
+
1646 1683
 $dbi->execute('create table book (id)');
1647 1684
 $dbi->execute('create table company (id, name);');
1648 1685
 $dbi->execute('create table test (id, name, primary key (id, name));');
... ...
@@ -1652,6 +1689,7 @@ is_deeply($dbi->model('company')->columns, ['id', 'name']);
1652 1689
 
1653 1690
 test 'delete_at';
1654 1691
 $dbi = DBIx::Custom->connect;
1692
+eval { $dbi->execute('drop table table1') };
1655 1693
 $dbi->execute($create_table1_2);
1656 1694
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1657 1695
 $dbi->delete_at(
... ...
@@ -1671,6 +1709,7 @@ is_deeply($dbi->select(table => 'table1')->all, []);
1671 1709
 
1672 1710
 test 'insert_at';
1673 1711
 $dbi = DBIx::Custom->connect;
1712
+eval { $dbi->execute('drop table table1') };
1674 1713
 $dbi->execute($create_table1_2);
1675 1714
 $dbi->insert_at(
1676 1715
     primary_key => ['key1', 'key2'], 
... ...
@@ -1706,6 +1745,7 @@ eval {
1706 1745
 like($@, qr/must be/);
1707 1746
 
1708 1747
 $dbi = DBIx::Custom->connect;
1748
+eval { $dbi->execute('drop table table1') };
1709 1749
 $dbi->execute($create_table1_2);
1710 1750
 $dbi->insert_at(
1711 1751
     {key3 => 3},