...
|
...
|
@@ -222,7 +222,7 @@ $result = $dbi->select(table => $table1);
|
222
|
222
|
like($result->one->{$key1}, qr/^2010-01-01/);
|
223
|
223
|
|
224
|
224
|
$dbi = DBIx::Custom->connect;
|
225
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
225
|
+eval { $dbi->execute("drop table $table1") };
|
226
|
226
|
$dbi->execute($create_table1_type);
|
227
|
227
|
$dbi->type_rule(
|
228
|
228
|
into1 => [
|
...
|
...
|
@@ -240,7 +240,7 @@ like($row->{$key1}, qr/^2010-01-03/);
|
240
|
240
|
like($row->{$key2}, qr/^2010-01-01 01:01:03/);
|
241
|
241
|
|
242
|
242
|
$dbi = DBIx::Custom->connect;
|
243
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
243
|
+eval { $dbi->execute("drop table $table1") };
|
244
|
244
|
$dbi->execute($create_table1_type);
|
245
|
245
|
$dbi->insert({$key1 => '2010-01-03', $key2 => '2010-01-01 01:01:03'}, table => $table1);
|
246
|
246
|
$dbi->type_rule(
|
...
|
...
|
@@ -261,7 +261,7 @@ like($row->{$key1}, qr/^2010-01-03/);
|
261
|
261
|
like($row->{$key2}, qr/^2010-01-01 01:01:03/);
|
262
|
262
|
|
263
|
263
|
$dbi = DBIx::Custom->connect;
|
264
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
264
|
+eval { $dbi->execute("drop table $table1") };
|
265
|
265
|
$dbi->execute($create_table1_type);
|
266
|
266
|
$dbi->insert({$key1 => '2010-01-03', $key2 => '2010-01-01 01:01:03'}, table => $table1);
|
267
|
267
|
$dbi->type_rule(
|
...
|
...
|
@@ -283,7 +283,7 @@ like($row->{$key1}, qr/^2010-01-03/);
|
283
|
283
|
like($row->{$key2}, qr/2010-01-01 01:01:03/);
|
284
|
284
|
|
285
|
285
|
$dbi = DBIx::Custom->connect;
|
286
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
286
|
+eval { $dbi->execute("drop table $table1") };
|
287
|
287
|
$dbi->execute($create_table1_type);
|
288
|
288
|
$dbi->register_filter(convert => sub {
|
289
|
289
|
my $value = shift || '';
|
...
|
...
|
@@ -304,7 +304,7 @@ like($result->fetch->[0], qr/^2010-03-03/);
|
304
|
304
|
|
305
|
305
|
test 'type_rule and filter order';
|
306
|
306
|
$dbi = DBIx::Custom->connect;
|
307
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
307
|
+eval { $dbi->execute("drop table $table1") };
|
308
|
308
|
$dbi->execute($create_table1_type);
|
309
|
309
|
$dbi->type_rule(
|
310
|
310
|
into1 => {
|
...
|
...
|
@@ -328,7 +328,7 @@ like($result->fetch_first->[0], qr/^2010-01-09/);
|
328
|
328
|
|
329
|
329
|
|
330
|
330
|
$dbi = DBIx::Custom->connect;
|
331
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
331
|
+eval { $dbi->execute("drop table $table1") };
|
332
|
332
|
$dbi->execute($create_table1_type);
|
333
|
333
|
$dbi->type_rule(
|
334
|
334
|
from1 => {
|
...
|
...
|
@@ -353,7 +353,7 @@ like($result->fetch_first->[0], qr/^2010-01-09/);
|
353
|
353
|
|
354
|
354
|
test 'type_rule_off';
|
355
|
355
|
$dbi = DBIx::Custom->connect;
|
356
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
356
|
+eval { $dbi->execute("drop table $table1") };
|
357
|
357
|
$dbi->execute($create_table1_type);
|
358
|
358
|
$dbi->type_rule(
|
359
|
359
|
from1 => {
|
...
|
...
|
@@ -368,7 +368,7 @@ $result = $dbi->select(table => $table1, type_rule_off => 1);
|
368
|
368
|
like($result->type_rule_off->fetch->[0], qr/^2010-01-03/);
|
369
|
369
|
|
370
|
370
|
$dbi = DBIx::Custom->connect;
|
371
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
371
|
+eval { $dbi->execute("drop table $table1") };
|
372
|
372
|
$dbi->execute($create_table1_type);
|
373
|
373
|
$dbi->type_rule(
|
374
|
374
|
from1 => {
|
...
|
...
|
@@ -383,7 +383,7 @@ $result = $dbi->select(table => $table1, type_rule_off => 1);
|
383
|
383
|
like($result->one->{$key1}, qr/^2010-01-04/);
|
384
|
384
|
|
385
|
385
|
$dbi = DBIx::Custom->connect;
|
386
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
386
|
+eval { $dbi->execute("drop table $table1") };
|
387
|
387
|
$dbi->execute($create_table1_type);
|
388
|
388
|
$dbi->type_rule(
|
389
|
389
|
from1 => {
|
...
|
...
|
@@ -398,7 +398,7 @@ $result = $dbi->select(table => $table1);
|
398
|
398
|
like($result->one->{$key1}, qr/^2010-01-05/);
|
399
|
399
|
|
400
|
400
|
$dbi = DBIx::Custom->connect;
|
401
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
401
|
+eval { $dbi->execute("drop table $table1") };
|
402
|
402
|
$dbi->execute($create_table1_type);
|
403
|
403
|
$dbi->type_rule(
|
404
|
404
|
from1 => {
|
...
|
...
|
@@ -413,7 +413,7 @@ $result = $dbi->select(table => $table1);
|
413
|
413
|
like($result->fetch->[0], qr/2010-01-05/);
|
414
|
414
|
|
415
|
415
|
$dbi = DBIx::Custom->connect;
|
416
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
416
|
+eval { $dbi->execute("drop table $table1") };
|
417
|
417
|
$dbi->execute($create_table1_type);
|
418
|
418
|
$dbi->register_filter(ppp => sub { my $v = shift || ''; $v =~ s/3/4/; return $v });
|
419
|
419
|
$dbi->type_rule(
|
...
|
...
|
@@ -433,7 +433,7 @@ eval{$dbi->type_rule(
|
433
|
433
|
like($@, qr/not registered/);
|
434
|
434
|
|
435
|
435
|
$dbi = DBIx::Custom->connect;
|
436
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
436
|
+eval { $dbi->execute("drop table $table1") };
|
437
|
437
|
$dbi->execute($create_table1_type);
|
438
|
438
|
eval {
|
439
|
439
|
$dbi->type_rule(
|
...
|
...
|
@@ -454,7 +454,7 @@ eval {
|
454
|
454
|
like($@, qr/lower/);
|
455
|
455
|
|
456
|
456
|
$dbi = DBIx::Custom->connect;
|
457
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
457
|
+eval { $dbi->execute("drop table $table1") };
|
458
|
458
|
$dbi->execute($create_table1_type);
|
459
|
459
|
$dbi->type_rule(
|
460
|
460
|
from1 => {
|
...
|
...
|
@@ -470,7 +470,7 @@ $result->type_rule_off;
|
470
|
470
|
like($result->one->{$key1}, qr/^2010-01-04/);
|
471
|
471
|
|
472
|
472
|
$dbi = DBIx::Custom->connect;
|
473
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
473
|
+eval { $dbi->execute("drop table $table1") };
|
474
|
474
|
$dbi->execute($create_table1_type);
|
475
|
475
|
$dbi->type_rule(
|
476
|
476
|
from1 => {
|
...
|
...
|
@@ -535,7 +535,7 @@ like($row->{$key1}, qr/^2010-01-03/);
|
535
|
535
|
like($row->{$key2}, qr/^2010-01-01 01:01:03/);
|
536
|
536
|
|
537
|
537
|
$dbi = DBIx::Custom->connect;
|
538
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
538
|
+eval { $dbi->execute("drop table $table1") };
|
539
|
539
|
$dbi->execute($create_table1_type);
|
540
|
540
|
$dbi->type_rule(
|
541
|
541
|
from1 => {
|
...
|
...
|
@@ -548,7 +548,7 @@ $result->filter($key1 => sub { my $v = shift || ''; $v =~ s/4/5/; return $v });
|
548
|
548
|
like($result->one->{$key1}, qr/^2010-01-05/);
|
549
|
549
|
|
550
|
550
|
$dbi = DBIx::Custom->connect;
|
551
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
551
|
+eval { $dbi->execute("drop table $table1") };
|
552
|
552
|
$dbi->execute($create_table1_type);
|
553
|
553
|
$dbi->type_rule(
|
554
|
554
|
from1 => {
|
...
|
...
|
@@ -561,7 +561,7 @@ $result->filter($key1 => sub { my $v = shift || ''; $v =~ s/4/5/; return $v });
|
561
|
561
|
like($result->fetch->[0], qr/^2010-01-05/);
|
562
|
562
|
|
563
|
563
|
$dbi = DBIx::Custom->connect;
|
564
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
564
|
+eval { $dbi->execute("drop table $table1") };
|
565
|
565
|
$dbi->execute($create_table1_type);
|
566
|
566
|
$dbi->type_rule(
|
567
|
567
|
into1 => {
|
...
|
...
|
@@ -584,7 +584,7 @@ $result = $dbi->select(table => $table1);
|
584
|
584
|
like($result->type_rule_on->fetch_first->[0], qr/^2010-01-07/);
|
585
|
585
|
|
586
|
586
|
$dbi = DBIx::Custom->connect;
|
587
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
587
|
+eval { $dbi->execute("drop table $table1") };
|
588
|
588
|
$dbi->execute($create_table1_type);
|
589
|
589
|
$dbi->type_rule(
|
590
|
590
|
into1 => {
|
...
|
...
|
@@ -607,7 +607,7 @@ $result = $dbi->select(table => $table1);
|
607
|
607
|
like($result->type_rule1_on->fetch_first->[0], qr/^2010-01-07/);
|
608
|
608
|
|
609
|
609
|
$dbi = DBIx::Custom->connect;
|
610
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
610
|
+eval { $dbi->execute("drop table $table1") };
|
611
|
611
|
$dbi->execute($create_table1_type);
|
612
|
612
|
$dbi->type_rule(
|
613
|
613
|
into1 => {
|
...
|
...
|
@@ -633,7 +633,7 @@ like($result->type_rule2_on->fetch_first->[0], qr/^2010-01-07/);
|
633
|
633
|
|
634
|
634
|
# Create table
|
635
|
635
|
$dbi = DBIx::Custom->connect;
|
636
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
636
|
+eval { $dbi->execute("drop table $table1") };
|
637
|
637
|
$dbi->execute($create_table1);
|
638
|
638
|
$model = $dbi->create_model(table => $table1);
|
639
|
639
|
$model->insert({$key1 => 1, $key2 => 2});
|
...
|
...
|
@@ -702,13 +702,13 @@ $insert_query = $dbi->execute($insert_source, {}, query => 1);
|
702
|
702
|
$dbi->execute($insert_query, param => {$key1 => 2, $key2 => 4});
|
703
|
703
|
$select_source = "select * from $table1 where {in $table1.$key1 2} and {in $table1.$key2 2}";
|
704
|
704
|
$select_query = $dbi->execute($select_source,{}, query => 1);
|
705
|
|
-$select_query->filter({'$table1.$key1' => 'twice'});
|
|
705
|
+$select_query->filter({"$table1.$key1" => 'twice'});
|
706
|
706
|
$result = $dbi->execute($select_query, param => {"$table1.$key1" => [1,5], "$table1.$key2" => [2,4]});
|
707
|
707
|
$rows = $result->all;
|
708
|
708
|
is_deeply($rows, [{$key1 => 2, $key2 => 4}], "filter");
|
709
|
709
|
|
710
|
710
|
test 'DBIx::Custom::SQLTemplate basic tag';
|
711
|
|
-$dbi->execute('drop table $table1');
|
|
711
|
+$dbi->execute("drop table $table1");
|
712
|
712
|
$dbi->execute($create_table1_2);
|
713
|
713
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
|
714
|
714
|
$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
|
...
|
...
|
@@ -732,7 +732,7 @@ $rows = $result->all;
|
732
|
732
|
is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}], "basic tag2");
|
733
|
733
|
|
734
|
734
|
test 'DIB::Custom::SQLTemplate in tag';
|
735
|
|
-$dbi->execute('drop table $table1');
|
|
735
|
+$dbi->execute("drop table $table1");
|
736
|
736
|
$dbi->execute($create_table1_2);
|
737
|
737
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
|
738
|
738
|
$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
|
...
|
...
|
@@ -767,7 +767,7 @@ is_deeply($rows, [{$key1 => 1, $key2 => 1, $key3 => 1, $key4 => 1, $key5 => 5},
|
767
|
767
|
{$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10}], "basic");
|
768
|
768
|
|
769
|
769
|
test 'Named placeholder';
|
770
|
|
-$dbi->execute('drop table $table1');
|
|
770
|
+$dbi->execute("drop table $table1");
|
771
|
771
|
$dbi->execute($create_table1_2);
|
772
|
772
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
|
773
|
773
|
$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
|
...
|
...
|
@@ -791,12 +791,12 @@ $source = "select * from $table1 where $key1 = :$table1.$key1 and $key2 = :$tabl
|
791
|
791
|
$result = $dbi->execute(
|
792
|
792
|
$source,
|
793
|
793
|
param => {"$table1.$key1" => 1, "$table1.$key2" => 1},
|
794
|
|
- filter => {'$table1.$key2' => sub { $_[0] * 2 }}
|
|
794
|
+ filter => {"$table1.$key2" => sub { $_[0] * 2 }}
|
795
|
795
|
);
|
796
|
796
|
$rows = $result->all;
|
797
|
797
|
is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}]);
|
798
|
798
|
|
799
|
|
-$dbi->execute('drop table $table1');
|
|
799
|
+$dbi->execute("drop table $table1");
|
800
|
800
|
$dbi->execute($create_table1);
|
801
|
801
|
$dbi->insert(table => $table1, param => {$key1 => '2011-10-14 12:19:18', $key2 => 2});
|
802
|
802
|
$source = "select * from $table1 where $key1 = '2011-10-14 12:19:18' and $key2 = :$key2";
|
...
|
...
|
@@ -827,7 +827,7 @@ eval{$dbi->execute("{p }", {}, query => 1)};
|
827
|
827
|
ok($@, "create_query invalid SQL template");
|
828
|
828
|
|
829
|
829
|
test 'insert';
|
830
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
830
|
+eval { $dbi->execute("drop table $table1") };
|
831
|
831
|
$dbi->execute($create_table1);
|
832
|
832
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
833
|
833
|
$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
|
...
|
...
|
@@ -835,7 +835,7 @@ $result = $dbi->execute("select * from $table1;");
|
835
|
835
|
$rows = $result->all;
|
836
|
836
|
is_deeply($rows, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], "basic");
|
837
|
837
|
|
838
|
|
-$dbi->execute('delete from $table1');
|
|
838
|
+$dbi->execute("delete from $table1");
|
839
|
839
|
$dbi->register_filter(
|
840
|
840
|
twice => sub { $_[0] * 2 },
|
841
|
841
|
three_times => sub { $_[0] * 3 }
|
...
|
...
|
@@ -847,7 +847,7 @@ $rows = $result->all;
|
847
|
847
|
is_deeply($rows, [{$key1 => 3, $key2 => 4}], "filter");
|
848
|
848
|
$dbi->default_bind_filter(undef);
|
849
|
849
|
|
850
|
|
-$dbi->execute('drop table $table1');
|
|
850
|
+$dbi->execute("drop table $table1");
|
851
|
851
|
$dbi->execute($create_table1);
|
852
|
852
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2}, append => ' ');
|
853
|
853
|
$rows = $dbi->select(table => $table1)->all;
|
...
|
...
|
@@ -867,7 +867,7 @@ $result = $dbi->execute("select * from ${q}table$p");
|
867
|
867
|
$rows = $result->all;
|
868
|
868
|
is_deeply($rows, [{select => 2, update => undef}], "reserved word");
|
869
|
869
|
|
870
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
870
|
+eval { $dbi->execute("drop table $table1") };
|
871
|
871
|
$dbi->execute($create_table1);
|
872
|
872
|
$dbi->insert({$key1 => 1, $key2 => 2}, table => $table1);
|
873
|
873
|
$dbi->insert({$key1 => 3, $key2 => 4}, table => $table1);
|
...
|
...
|
@@ -875,7 +875,7 @@ $result = $dbi->execute("select * from $table1;");
|
875
|
875
|
$rows = $result->all;
|
876
|
876
|
is_deeply($rows, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], "basic");
|
877
|
877
|
|
878
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
878
|
+eval { $dbi->execute("drop table $table1") };
|
879
|
879
|
$dbi->execute($create_table1);
|
880
|
880
|
$dbi->insert(table => $table1, param => {$key1 => \"'1'", $key2 => 2});
|
881
|
881
|
$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
|
...
|
...
|
@@ -884,7 +884,7 @@ $rows = $result->all;
|
884
|
884
|
is_deeply($rows, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], "basic");
|
885
|
885
|
|
886
|
886
|
test 'update';
|
887
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
887
|
+eval { $dbi->execute("drop table $table1") };
|
888
|
888
|
$dbi->execute($create_table1_2);
|
889
|
889
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
|
890
|
890
|
$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
|
...
|
...
|
@@ -932,7 +932,7 @@ like($@, qr/noexist/, "invalid");
|
932
|
932
|
eval{$dbi->update(table => $table1)};
|
933
|
933
|
like($@, qr/where/, "not contain where");
|
934
|
934
|
|
935
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
935
|
+eval { $dbi->execute("drop table $table1") };
|
936
|
936
|
$dbi->execute($create_table1);
|
937
|
937
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
938
|
938
|
$where = $dbi->where;
|
...
|
...
|
@@ -942,7 +942,7 @@ $dbi->update(table => $table1, param => {$key1 => 3}, where => $where);
|
942
|
942
|
$result = $dbi->select(table => $table1);
|
943
|
943
|
is_deeply($result->all, [{$key1 => 3, $key2 => 2}], 'update() where');
|
944
|
944
|
|
945
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
945
|
+eval { $dbi->execute("drop table $table1") };
|
946
|
946
|
$dbi->execute($create_table1);
|
947
|
947
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
948
|
948
|
$dbi->update(
|
...
|
...
|
@@ -956,7 +956,7 @@ $dbi->update(
|
956
|
956
|
$result = $dbi->select(table => $table1);
|
957
|
957
|
is_deeply($result->all, [{$key1 => 3, $key2 => 2}], 'update() where');
|
958
|
958
|
|
959
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
959
|
+eval { $dbi->execute("drop table $table1") };
|
960
|
960
|
$dbi->execute($create_table1);
|
961
|
961
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
962
|
962
|
$where = $dbi->where;
|
...
|
...
|
@@ -972,7 +972,7 @@ like($@, qr/safety/);
|
972
|
972
|
eval{$dbi->update(table => $table1, param => {$key1 => 1}, where => {';' => 1})};
|
973
|
973
|
like($@, qr/safety/);
|
974
|
974
|
|
975
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
975
|
+eval { $dbi->execute("drop table $table1") };
|
976
|
976
|
eval { $dbi->execute("drop table ${q}table$p") };
|
977
|
977
|
$dbi->execute($create_table_reserved);
|
978
|
978
|
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
|
...
|
...
|
@@ -996,7 +996,7 @@ $result = $dbi->execute("select * from ${q}table$p");
|
996
|
996
|
$rows = $result->all;
|
997
|
997
|
is_deeply($rows, [{select => 2, update => 6}], "reserved word");
|
998
|
998
|
|
999
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
999
|
+eval { $dbi->execute("drop table $table1") };
|
1000
|
1000
|
$dbi->execute($create_table1_2);
|
1001
|
1001
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
|
1002
|
1002
|
$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
|
...
|
...
|
@@ -1007,7 +1007,7 @@ is_deeply($rows, [{$key1 => 1, $key2 => 11, $key3 => 3, $key4 => 4, $key5 => 5},
|
1007
|
1007
|
{$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10}],
|
1008
|
1008
|
"basic");
|
1009
|
1009
|
|
1010
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1010
|
+eval { $dbi->execute("drop table $table1") };
|
1011
|
1011
|
$dbi->execute($create_table1_2);
|
1012
|
1012
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
|
1013
|
1013
|
$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
|
...
|
...
|
@@ -1019,7 +1019,7 @@ is_deeply($rows, [{$key1 => 1, $key2 => 11, $key3 => 3, $key4 => 4, $key5 => 5},
|
1019
|
1019
|
"basic");
|
1020
|
1020
|
|
1021
|
1021
|
test 'update_all';
|
1022
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1022
|
+eval { $dbi->execute("drop table $table1") };
|
1023
|
1023
|
$dbi->execute($create_table1_2);
|
1024
|
1024
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
|
1025
|
1025
|
$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
|
...
|
...
|
@@ -1033,7 +1033,7 @@ is_deeply($rows, [{$key1 => 1, $key2 => 20, $key3 => 3, $key4 => 4, $key5 => 5},
|
1033
|
1033
|
|
1034
|
1034
|
|
1035
|
1035
|
test 'delete';
|
1036
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1036
|
+eval { $dbi->execute("drop table $table1") };
|
1037
|
1037
|
$dbi->execute($create_table1);
|
1038
|
1038
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1039
|
1039
|
$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
|
...
|
...
|
@@ -1063,7 +1063,7 @@ is_deeply($rows, [{$key1 => 3, $key2 => 4}], "delete multi key");
|
1063
|
1063
|
eval{$dbi->delete(table => $table1, where => {$key1 => 1}, noexist => 1)};
|
1064
|
1064
|
like($@, qr/noexist/, "invalid");
|
1065
|
1065
|
|
1066
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1066
|
+eval { $dbi->execute("drop table $table1") };
|
1067
|
1067
|
$dbi->execute($create_table1);
|
1068
|
1068
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1069
|
1069
|
$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
|
...
|
...
|
@@ -1074,7 +1074,7 @@ $dbi->delete(table => $table1, where => $where);
|
1074
|
1074
|
$result = $dbi->select(table => $table1);
|
1075
|
1075
|
is_deeply($result->all, [{$key1 => 3, $key2 => 4}], 'delete() where');
|
1076
|
1076
|
|
1077
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1077
|
+eval { $dbi->execute("drop table $table1") };
|
1078
|
1078
|
$dbi->execute($create_table1);
|
1079
|
1079
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1080
|
1080
|
$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
|
...
|
...
|
@@ -1088,7 +1088,7 @@ $dbi->delete(
|
1088
|
1088
|
$result = $dbi->select(table => $table1);
|
1089
|
1089
|
is_deeply($result->all, [{$key1 => 3, $key2 => 4}], 'delete() where');
|
1090
|
1090
|
|
1091
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1091
|
+eval { $dbi->execute("drop table $table1") };
|
1092
|
1092
|
$dbi->execute($create_table1);
|
1093
|
1093
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1094
|
1094
|
$dbi->delete(table => $table1, where => {$key1 => 1}, prefix => ' ');
|
...
|
...
|
@@ -1097,7 +1097,7 @@ $rows = $result->all;
|
1097
|
1097
|
is_deeply($rows, [], "basic");
|
1098
|
1098
|
|
1099
|
1099
|
test 'delete error';
|
1100
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1100
|
+eval { $dbi->execute("drop table $table1") };
|
1101
|
1101
|
$dbi->execute($create_table1);
|
1102
|
1102
|
eval{$dbi->delete(table => $table1)};
|
1103
|
1103
|
like($@, qr/"where" must be specified/,
|
...
|
...
|
@@ -1118,7 +1118,7 @@ $rows = $result->all;
|
1118
|
1118
|
is_deeply($rows, [], "reserved word");
|
1119
|
1119
|
|
1120
|
1120
|
test 'delete_all';
|
1121
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1121
|
+eval { $dbi->execute("drop table $table1") };
|
1122
|
1122
|
$dbi->execute($create_table1);
|
1123
|
1123
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1124
|
1124
|
$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
|
...
|
...
|
@@ -1129,7 +1129,7 @@ is_deeply($rows, [], "basic");
|
1129
|
1129
|
|
1130
|
1130
|
|
1131
|
1131
|
test 'select';
|
1132
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1132
|
+eval { $dbi->execute("drop table $table1") };
|
1133
|
1133
|
$dbi->execute($create_table1);
|
1134
|
1134
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1135
|
1135
|
$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
|
...
|
...
|
@@ -1164,7 +1164,7 @@ is_deeply($rows, [{"${table1}_$key1" => 1, "${table2}_$key1" => 1, $key2 => 2, $
|
1164
|
1164
|
|
1165
|
1165
|
$rows = $dbi->select(
|
1166
|
1166
|
table => [$table1, $table2],
|
1167
|
|
- column => ["$table1.$key1 as ${table1}_$key1', '${table2}.$key1 as ${table2}_$key1", $key2, $key3],
|
|
1167
|
+ column => ["$table1.$key1 as ${table1}_$key1", "${table2}.$key1 as ${table2}_$key1", $key2, $key3],
|
1168
|
1168
|
relation => {"$table1.$key1" => "$table2.$key1"}
|
1169
|
1169
|
)->all;
|
1170
|
1170
|
is_deeply($rows, [{"${table1}_$key1" => 1, "${table2}_$key1" => 1, $key2 => 2, $key3 => 5}], "relation : no exists where");
|
...
|
...
|
@@ -1182,7 +1182,7 @@ $rows = $result->all;
|
1182
|
1182
|
is_deeply($rows, [{select => 2, update => 2}], "reserved word");
|
1183
|
1183
|
|
1184
|
1184
|
test 'fetch filter';
|
1185
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1185
|
+eval { $dbi->execute("drop table $table1") };
|
1186
|
1186
|
$dbi->register_filter(
|
1187
|
1187
|
twice => sub { $_[0] * 2 },
|
1188
|
1188
|
three_times => sub { $_[0] * 3 }
|
...
|
...
|
@@ -1206,7 +1206,7 @@ is($dbi->filters->{encode_utf8}->('あ'),
|
1206
|
1206
|
|
1207
|
1207
|
test 'transaction1';
|
1208
|
1208
|
$dbi = DBIx::Custom->connect;
|
1209
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1209
|
+eval { $dbi->execute("drop table $table1") };
|
1210
|
1210
|
$dbi->execute($create_table1);
|
1211
|
1211
|
$dbi->begin_work;
|
1212
|
1212
|
$dbi->dbh->{AutoCommit} = 0;
|
...
|
...
|
@@ -1219,7 +1219,7 @@ ok(! $result->fetch_first, "rollback");
|
1219
|
1219
|
|
1220
|
1220
|
|
1221
|
1221
|
$dbi = DBIx::Custom->connect;
|
1222
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1222
|
+eval { $dbi->execute("drop table $table1") };
|
1223
|
1223
|
$dbi->execute($create_table1);
|
1224
|
1224
|
$dbi->begin_work;
|
1225
|
1225
|
$dbi->dbh->{AutoCommit} = 0;
|
...
|
...
|
@@ -1232,17 +1232,17 @@ is_deeply(scalar $result->all, [{$key1 => 1, $key2 => 2}, {$key1 => 2, $key2 =>
|
1232
|
1232
|
"commit");
|
1233
|
1233
|
|
1234
|
1234
|
test 'execute';
|
1235
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1235
|
+eval { $dbi->execute("drop table $table1") };
|
1236
|
1236
|
$dbi->execute($create_table1);
|
1237
|
1237
|
{
|
1238
|
1238
|
local $Carp::Verbose = 0;
|
1239
|
|
- eval{$dbi->execute('select * frm $table1')};
|
|
1239
|
+ eval{$dbi->execute("select * frm $table1")};
|
1240
|
1240
|
like($@, qr/\Qselect * frm $table1;/, "fail prepare");
|
1241
|
1241
|
like($@, qr/\.t /, "fail : not verbose");
|
1242
|
1242
|
}
|
1243
|
1243
|
{
|
1244
|
1244
|
local $Carp::Verbose = 1;
|
1245
|
|
- eval{$dbi->execute('select * frm $table1')};
|
|
1245
|
+ eval{$dbi->execute("select * frm $table1")};
|
1246
|
1246
|
like($@, qr/Custom.*\.t /s, "fail : verbose");
|
1247
|
1247
|
}
|
1248
|
1248
|
|
...
|
...
|
@@ -1268,7 +1268,7 @@ ok($@, "execute fail");
|
1268
|
1268
|
|
1269
|
1269
|
test 'transaction2';
|
1270
|
1270
|
$dbi = DBIx::Custom->connect;
|
1271
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1271
|
+eval { $dbi->execute("drop table $table1") };
|
1272
|
1272
|
$dbi->execute($create_table1);
|
1273
|
1273
|
|
1274
|
1274
|
$dbi->begin_work;
|
...
|
...
|
@@ -1304,7 +1304,7 @@ ok($@, "exception");
|
1304
|
1304
|
$dbi->dbh->{AutoCommit} = 1;
|
1305
|
1305
|
|
1306
|
1306
|
test 'cache';
|
1307
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1307
|
+eval { $dbi->execute("drop table $table1") };
|
1308
|
1308
|
$dbi->cache(1);
|
1309
|
1309
|
$dbi->execute($create_table1);
|
1310
|
1310
|
$source = "select * from $table1 where $key1 = :$key1 and $key2 = :$key2;";
|
...
|
...
|
@@ -1312,7 +1312,7 @@ $dbi->execute($source, {}, query => 1);
|
1312
|
1312
|
is_deeply($dbi->{_cached}->{$source},
|
1313
|
1313
|
{sql => "select * from $table1 where $key1 = ? and $key2 = ?;", columns => [$key1, $key2], tables => []}, "cache");
|
1314
|
1314
|
|
1315
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1315
|
+eval { $dbi->execute("drop table $table1") };
|
1316
|
1316
|
$dbi->execute($create_table1);
|
1317
|
1317
|
$dbi->{_cached} = {};
|
1318
|
1318
|
$dbi->cache(0);
|
...
|
...
|
@@ -1320,11 +1320,11 @@ $dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1320
|
1320
|
is(scalar keys %{$dbi->{_cached}}, 0, 'not cache');
|
1321
|
1321
|
|
1322
|
1322
|
test 'execute';
|
1323
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1323
|
+eval { $dbi->execute("drop table $table1") };
|
1324
|
1324
|
$dbi->execute($create_table1);
|
1325
|
1325
|
{
|
1326
|
1326
|
local $Carp::Verbose = 0;
|
1327
|
|
- eval{$dbi->execute('select * frm $table1')};
|
|
1327
|
+ eval{$dbi->execute("select * frm $table1")};
|
1328
|
1328
|
like($@, qr/\Qselect * frm $table1;/, "fail prepare");
|
1329
|
1329
|
like($@, qr/\.t /, "fail : not verbose");
|
1330
|
1330
|
}
|
...
|
...
|
@@ -1376,7 +1376,7 @@ ok($@, "not exists");
|
1376
|
1376
|
|
1377
|
1377
|
test 'out filter';
|
1378
|
1378
|
$dbi = DBIx::Custom->connect;
|
1379
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1379
|
+eval { $dbi->execute("drop table $table1") };
|
1380
|
1380
|
$dbi->execute($create_table1);
|
1381
|
1381
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
1382
|
1382
|
$dbi->register_filter(three_times => sub { $_[0] * 3});
|
...
|
...
|
@@ -1392,7 +1392,7 @@ $row = $result->one;
|
1392
|
1392
|
is_deeply($row, {$key1 => 6, $key2 => 12}, "insert");
|
1393
|
1393
|
|
1394
|
1394
|
$dbi = DBIx::Custom->connect;
|
1395
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1395
|
+eval { $dbi->execute("drop table $table1") };
|
1396
|
1396
|
$dbi->execute($create_table1);
|
1397
|
1397
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
1398
|
1398
|
$dbi->register_filter(three_times => sub { $_[0] * 3});
|
...
|
...
|
@@ -1408,7 +1408,7 @@ $row = $result->one;
|
1408
|
1408
|
is_deeply($row, {$key1 => 1, $key2 => 6}, "insert");
|
1409
|
1409
|
|
1410
|
1410
|
$dbi = DBIx::Custom->connect;
|
1411
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1411
|
+eval { $dbi->execute("drop table $table1") };
|
1412
|
1412
|
$dbi->execute($create_table1);
|
1413
|
1413
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
1414
|
1414
|
$dbi->apply_filter(
|
...
|
...
|
@@ -1421,7 +1421,7 @@ $row = $result->one;
|
1421
|
1421
|
is_deeply($row, {$key1 => 4, $key2 => 2}, "update");
|
1422
|
1422
|
|
1423
|
1423
|
$dbi = DBIx::Custom->connect;
|
1424
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1424
|
+eval { $dbi->execute("drop table $table1") };
|
1425
|
1425
|
$dbi->execute($create_table1);
|
1426
|
1426
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
1427
|
1427
|
$dbi->apply_filter(
|
...
|
...
|
@@ -1434,7 +1434,7 @@ $rows = $result->all;
|
1434
|
1434
|
is_deeply($rows, [], "delete");
|
1435
|
1435
|
|
1436
|
1436
|
$dbi = DBIx::Custom->connect;
|
1437
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1437
|
+eval { $dbi->execute("drop table $table1") };
|
1438
|
1438
|
$dbi->execute($create_table1);
|
1439
|
1439
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
1440
|
1440
|
$dbi->apply_filter(
|
...
|
...
|
@@ -1447,7 +1447,7 @@ $rows = $result->all;
|
1447
|
1447
|
is_deeply($rows, [{$key1 => 4, $key2 => 4}], "select");
|
1448
|
1448
|
|
1449
|
1449
|
$dbi = DBIx::Custom->connect;
|
1450
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1450
|
+eval { $dbi->execute("drop table $table1") };
|
1451
|
1451
|
$dbi->execute($create_table1);
|
1452
|
1452
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
1453
|
1453
|
$dbi->apply_filter(
|
...
|
...
|
@@ -1461,7 +1461,7 @@ $rows = $result->all;
|
1461
|
1461
|
is_deeply($rows, [{$key1 => 4, $key2 => 2}], "execute");
|
1462
|
1462
|
|
1463
|
1463
|
$dbi = DBIx::Custom->connect;
|
1464
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1464
|
+eval { $dbi->execute("drop table $table1") };
|
1465
|
1465
|
$dbi->execute($create_table1);
|
1466
|
1466
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
1467
|
1467
|
$dbi->apply_filter(
|
...
|
...
|
@@ -1474,8 +1474,8 @@ $rows = $result->all;
|
1474
|
1474
|
is_deeply($rows, [{$key1 => 4, $key2 => 2}], "execute table tag");
|
1475
|
1475
|
|
1476
|
1476
|
$dbi = DBIx::Custom->connect;
|
1477
|
|
-eval { $dbi->execute('drop table $table1') };
|
1478
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
1477
|
+eval { $dbi->execute("drop table $table1") };
|
|
1478
|
+eval { $dbi->execute("drop table $table2") };
|
1479
|
1479
|
$dbi->execute($create_table1);
|
1480
|
1480
|
$dbi->execute($create_table2);
|
1481
|
1481
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
...
|
...
|
@@ -1509,9 +1509,9 @@ is_deeply($rows, [{$key2 => 4, $key3 => 18}], "select : join : omit");
|
1509
|
1509
|
test 'each_column';
|
1510
|
1510
|
$dbi = DBIx::Custom->connect;
|
1511
|
1511
|
eval { $dbi->execute("drop table ${q}table$p") };
|
1512
|
|
-eval { $dbi->execute('drop table $table1') };
|
1513
|
|
-eval { $dbi->execute('drop table $table2') };
|
1514
|
|
-eval { $dbi->execute('drop table $table3') };
|
|
1512
|
+eval { $dbi->execute("drop table $table1") };
|
|
1513
|
+eval { $dbi->execute("drop table $table2") };
|
|
1514
|
+eval { $dbi->execute("drop table $table3") };
|
1515
|
1515
|
$dbi->execute($create_table1_type);
|
1516
|
1516
|
$dbi->execute($create_table2);
|
1517
|
1517
|
|
...
|
...
|
@@ -1536,8 +1536,8 @@ is_deeply($infos,
|
1536
|
1536
|
);
|
1537
|
1537
|
test 'each_table';
|
1538
|
1538
|
$dbi = DBIx::Custom->connect;
|
1539
|
|
-eval { $dbi->execute('drop table $table1') };
|
1540
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
1539
|
+eval { $dbi->execute("drop table $table1") };
|
|
1540
|
+eval { $dbi->execute("drop table $table2") };
|
1541
|
1541
|
$dbi->execute($create_table2);
|
1542
|
1542
|
$dbi->execute($create_table1_type);
|
1543
|
1543
|
|
...
|
...
|
@@ -1560,27 +1560,27 @@ is_deeply($infos,
|
1560
|
1560
|
|
1561
|
1561
|
test 'connect super';
|
1562
|
1562
|
$dbi = DBIx::Custom->connect;
|
1563
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1563
|
+eval { $dbi->execute("drop table $table1") };
|
1564
|
1564
|
$dbi->execute($create_table1);
|
1565
|
1565
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1566
|
1566
|
is($dbi->select(table => $table1)->one->{$key1}, 1);
|
1567
|
1567
|
|
1568
|
1568
|
$dbi = DBIx::Custom->new;
|
1569
|
1569
|
$dbi->connect;
|
1570
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1570
|
+eval { $dbi->execute("drop table $table1") };
|
1571
|
1571
|
$dbi->execute($create_table1);
|
1572
|
1572
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1573
|
1573
|
is($dbi->select(table => $table1)->one->{$key1}, 1);
|
1574
|
1574
|
|
1575
|
1575
|
$dbi = DBIx::Custom->connect;
|
1576
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1576
|
+eval { $dbi->execute("drop table $table1") };
|
1577
|
1577
|
$dbi->execute($create_table1);
|
1578
|
1578
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1579
|
1579
|
is($dbi->select(table => $table1)->one->{$key1}, 1);
|
1580
|
1580
|
|
1581
|
1581
|
test 'end_filter';
|
1582
|
1582
|
$dbi = DBIx::Custom->connect;
|
1583
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1583
|
+eval { $dbi->execute("drop table $table1") };
|
1584
|
1584
|
$dbi->execute($create_table1);
|
1585
|
1585
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1586
|
1586
|
$result = $dbi->select(table => $table1);
|
...
|
...
|
@@ -1590,22 +1590,22 @@ $row = $result->fetch_first;
|
1590
|
1590
|
is_deeply($row, [6, 40]);
|
1591
|
1591
|
|
1592
|
1592
|
$dbi = DBIx::Custom->connect;
|
1593
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1593
|
+eval { $dbi->execute("drop table $table1") };
|
1594
|
1594
|
$dbi->execute($create_table1);
|
1595
|
1595
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1596
|
1596
|
$result = $dbi->select(table => $table1);
|
1597
|
|
-$result->filter([qw/$key1 $key2/] => sub { $_[0] * 2 });
|
1598
|
|
-$result->end_filter([[qw/$key1 $key2/] => sub { $_[0] * 3 }]);
|
|
1597
|
+$result->filter([$key1, $key2] => sub { $_[0] * 2 });
|
|
1598
|
+$result->end_filter([[$key1, $key2] => sub { $_[0] * 3 }]);
|
1599
|
1599
|
$row = $result->fetch_first;
|
1600
|
1600
|
is_deeply($row, [6, 12]);
|
1601
|
1601
|
|
1602
|
1602
|
$dbi = DBIx::Custom->connect;
|
1603
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1603
|
+eval { $dbi->execute("drop table $table1") };
|
1604
|
1604
|
$dbi->execute($create_table1);
|
1605
|
1605
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1606
|
1606
|
$result = $dbi->select(table => $table1);
|
1607
|
|
-$result->filter([[qw/$key1 $key2/] => sub { $_[0] * 2 }]);
|
1608
|
|
-$result->end_filter([qw/$key1 $key2/] => sub { $_[0] * 3 });
|
|
1607
|
+$result->filter([[$key1, $key2] => sub { $_[0] * 2 }]);
|
|
1608
|
+$result->end_filter([$key1, $key2] => sub { $_[0] * 3 });
|
1609
|
1609
|
$row = $result->fetch_first;
|
1610
|
1610
|
is_deeply($row, [6, 12]);
|
1611
|
1611
|
|
...
|
...
|
@@ -1640,7 +1640,7 @@ is_deeply($row, {$key1 => 1, $key2 => 40}, 'apply_filter overwrite');
|
1640
|
1640
|
|
1641
|
1641
|
test 'remove_end_filter and remove_filter';
|
1642
|
1642
|
$dbi = DBIx::Custom->connect;
|
1643
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1643
|
+eval { $dbi->execute("drop table $table1") };
|
1644
|
1644
|
$dbi->execute($create_table1);
|
1645
|
1645
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1646
|
1646
|
$result = $dbi->select(table => $table1);
|
...
|
...
|
@@ -1654,7 +1654,7 @@ is_deeply($row, [1, 2]);
|
1654
|
1654
|
|
1655
|
1655
|
test 'empty where select';
|
1656
|
1656
|
$dbi = DBIx::Custom->connect;
|
1657
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1657
|
+eval { $dbi->execute("drop table $table1") };
|
1658
|
1658
|
$dbi->execute($create_table1);
|
1659
|
1659
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1660
|
1660
|
$result = $dbi->select(table => $table1, where => {});
|
...
|
...
|
@@ -1663,7 +1663,7 @@ is_deeply($row, {$key1 => 1, $key2 => 2});
|
1663
|
1663
|
|
1664
|
1664
|
test 'select query option';
|
1665
|
1665
|
$dbi = DBIx::Custom->connect;
|
1666
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1666
|
+eval { $dbi->execute("drop table $table1") };
|
1667
|
1667
|
$dbi->execute($create_table1);
|
1668
|
1668
|
$query = $dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2}, query => 1);
|
1669
|
1669
|
is(ref $query, 'DBIx::Custom::Query');
|
...
|
...
|
@@ -1676,7 +1676,7 @@ is(ref $query, 'DBIx::Custom::Query');
|
1676
|
1676
|
|
1677
|
1677
|
test 'where';
|
1678
|
1678
|
$dbi = DBIx::Custom->connect;
|
1679
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
1679
|
+eval { $dbi->execute("drop table $table1") };
|
1680
|
1680
|
$dbi->execute($create_table1);
|
1681
|
1681
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
1682
|
1682
|
$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
|
...
|
...
|
@@ -1786,7 +1786,7 @@ $row = $result->all;
|
1786
|
1786
|
is_deeply($row, [{$key1 => 1, $key2 => 2}]);
|
1787
|
1787
|
|
1788
|
1788
|
$where = $dbi->where
|
1789
|
|
- ->clause('$key1 = :$key1')
|
|
1789
|
+ ->clause("$key1 = :$key1")
|
1790
|
1790
|
->param({$key1 => 1});
|
1791
|
1791
|
$result = $dbi->select(
|
1792
|
1792
|
table => $table1,
|
...
|
...
|
@@ -2032,19 +2032,19 @@ is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}]);
|
2032
|
2032
|
|
2033
|
2033
|
$where = $dbi->where;
|
2034
|
2034
|
$where->param({id => 1, author => 'Ken', price => 1900});
|
2035
|
|
-$where->map(id => '$table1.id',
|
2036
|
|
- author => ['$table1.author', sub { '%' . $_[0] . '%' }],
|
2037
|
|
- price => ['$table1.price', {if => sub { $_[0] eq 1900 }}]
|
|
2035
|
+$where->map(id => "$table1.id",
|
|
2036
|
+ author => ["$table1.author", sub { '%' . $_[0] . '%' }],
|
|
2037
|
+ price => ["$table1.price", {if => sub { $_[0] eq 1900 }}]
|
2038
|
2038
|
);
|
2039
|
2039
|
is_deeply($where->param, {"$table1.id" => 1, "$table1.author" => '%Ken%',
|
2040
|
|
- '$table1.price' => 1900});
|
|
2040
|
+ "$table1.price" => 1900});
|
2041
|
2041
|
|
2042
|
2042
|
$where = $dbi->where;
|
2043
|
2043
|
$where->param({id => 0, author => 0, price => 0});
|
2044
|
2044
|
$where->map(
|
2045
|
|
- id => '$table1.id',
|
2046
|
|
- author => ['$table1.author', sub { '%' . $_[0] . '%' }],
|
2047
|
|
- price => ['$table1.price', sub { '%' . $_[0] . '%' },
|
|
2045
|
+ id => "$table1.id",
|
|
2046
|
+ author => ["$table1.author", sub { '%' . $_[0] . '%' }],
|
|
2047
|
+ price => ["$table1.price", sub { '%' . $_[0] . '%' },
|
2048
|
2048
|
{if => sub { $_[0] eq 0 }}]
|
2049
|
2049
|
);
|
2050
|
2050
|
is_deeply($where->param, {"$table1.id" => 0, "$table1.author" => '%0%', "$table1.price" => '%0%'});
|
...
|
...
|
@@ -2053,9 +2053,9 @@ $where = $dbi->where;
|
2053
|
2053
|
$where->param({id => '', author => '', price => ''});
|
2054
|
2054
|
$where->if('length');
|
2055
|
2055
|
$where->map(
|
2056
|
|
- id => '$table1.id',
|
2057
|
|
- author => ['$table1.author', sub { '%' . $_[0] . '%' }],
|
2058
|
|
- price => ['$table1.price', sub { '%' . $_[0] . '%' },
|
|
2056
|
+ id => "$table1.id",
|
|
2057
|
+ author => ["$table1.author", sub { '%' . $_[0] . '%' }],
|
|
2058
|
+ price => ["$table1.price", sub { '%' . $_[0] . '%' },
|
2059
|
2059
|
{if => sub { $_[0] eq 1 }}]
|
2060
|
2060
|
);
|
2061
|
2061
|
is_deeply($where->param, {});
|
...
|
...
|
@@ -2064,50 +2064,50 @@ $where = $dbi->where;
|
2064
|
2064
|
$where->param({id => undef, author => undef, price => undef});
|
2065
|
2065
|
$where->if('length');
|
2066
|
2066
|
$where->map(
|
2067
|
|
- id => '$table1.id',
|
2068
|
|
- price => ['$table1.price', {if => 'exists'}]
|
|
2067
|
+ id => "$table1.id",
|
|
2068
|
+ price => ["$table1.price", {if => 'exists'}]
|
2069
|
2069
|
);
|
2070
|
|
-is_deeply($where->param, {'$table1.price' => undef});
|
|
2070
|
+is_deeply($where->param, {"$table1.price" => undef});
|
2071
|
2071
|
|
2072
|
2072
|
$where = $dbi->where;
|
2073
|
2073
|
$where->param({price => 'a'});
|
2074
|
2074
|
$where->if('length');
|
2075
|
2075
|
$where->map(
|
2076
|
|
- id => ['$table1.id', {if => 'exists'}],
|
2077
|
|
- price => ['$table1.price', sub { '%' . $_[0] }, {if => 'exists'}]
|
|
2076
|
+ id => ["$table1.id", {if => 'exists'}],
|
|
2077
|
+ price => ["$table1.price", sub { '%' . $_[0] }, {if => 'exists'}]
|
2078
|
2078
|
);
|
2079
|
|
-is_deeply($where->param, {'$table1.price' => '%a'});
|
|
2079
|
+is_deeply($where->param, {"$table1.price" => '%a'});
|
2080
|
2080
|
|
2081
|
2081
|
$where = $dbi->where;
|
2082
|
2082
|
$where->param({id => [1, 2], author => 'Ken', price => 1900});
|
2083
|
2083
|
$where->map(
|
2084
|
|
- id => '$table1.id',
|
2085
|
|
- author => ['$table1.author', sub { '%' . $_[0] . '%' }],
|
2086
|
|
- price => ['$table1.price', {if => sub { $_[0] eq 1900 }}]
|
|
2084
|
+ id => "$table1.id",
|
|
2085
|
+ author => ["$table1.author", sub { '%' . $_[0] . '%' }],
|
|
2086
|
+ price => ["$table1.price", {if => sub { $_[0] eq 1900 }}]
|
2087
|
2087
|
);
|
2088
|
2088
|
is_deeply($where->param, {"$table1.id" => [1, 2], "$table1.author" => '%Ken%',
|
2089
|
|
- '$table1.price' => 1900});
|
|
2089
|
+ "$table1.price" => 1900});
|
2090
|
2090
|
|
2091
|
2091
|
$where = $dbi->where;
|
2092
|
2092
|
$where->if('length');
|
2093
|
2093
|
$where->param({id => ['', ''], author => 'Ken', price => 1900});
|
2094
|
2094
|
$where->map(
|
2095
|
|
- id => '$table1.id',
|
2096
|
|
- author => ['$table1.author', sub { '%' . $_[0] . '%' }],
|
2097
|
|
- price => ['$table1.price', {if => sub { $_[0] eq 1900 }}]
|
|
2095
|
+ id => "$table1.id",
|
|
2096
|
+ author => ["$table1.author", sub { '%' . $_[0] . '%' }],
|
|
2097
|
+ price => ["$table1.price", {if => sub { $_[0] eq 1900 }}]
|
2098
|
2098
|
);
|
2099
|
2099
|
is_deeply($where->param, {"$table1.id" => [$dbi->not_exists, $dbi->not_exists], "$table1.author" => '%Ken%',
|
2100
|
|
- '$table1.price' => 1900});
|
|
2100
|
+ "$table1.price" => 1900});
|
2101
|
2101
|
|
2102
|
2102
|
$where = $dbi->where;
|
2103
|
2103
|
$where->param({id => ['', ''], author => 'Ken', price => 1900});
|
2104
|
2104
|
$where->map(
|
2105
|
|
- id => ['$table1.id', {if => 'length'}],
|
2106
|
|
- author => ['$table1.author', sub { '%' . $_[0] . '%' }, {if => 'defined'}],
|
2107
|
|
- price => ['$table1.price', {if => sub { $_[0] eq 1900 }}]
|
|
2105
|
+ id => ["$table1.id", {if => 'length'}],
|
|
2106
|
+ author => ["$table1.author", sub { '%' . $_[0] . '%' }, {if => 'defined'}],
|
|
2107
|
+ price => ["$table1.price", {if => sub { $_[0] eq 1900 }}]
|
2108
|
2108
|
);
|
2109
|
2109
|
is_deeply($where->param, {"$table1.id" => [$dbi->not_exists, $dbi->not_exists], "$table1.author" => '%Ken%',
|
2110
|
|
- '$table1.price' => 1900});
|
|
2110
|
+ "$table1.price" => 1900});
|
2111
|
2111
|
|
2112
|
2112
|
test 'dbi_option default';
|
2113
|
2113
|
$dbi = DBIx::Custom->new;
|
...
|
...
|
@@ -2150,7 +2150,7 @@ $dbi->apply_filter(
|
2150
|
2150
|
|
2151
|
2151
|
);
|
2152
|
2152
|
$dbi = DBIx::Custom->connect;
|
2153
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2153
|
+eval { $dbi->execute("drop table $table1") };
|
2154
|
2154
|
$dbi->execute($create_table1);
|
2155
|
2155
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
2156
|
2156
|
$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
|
...
|
...
|
@@ -2160,7 +2160,7 @@ $rows = $dbi->select(table => $table1, where => {$key2 => 1})->all;
|
2160
|
2160
|
is_deeply($rows, [{$key1 => 1, $key2 => 6}]);
|
2161
|
2161
|
|
2162
|
2162
|
$dbi = DBIx::Custom->connect;
|
2163
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2163
|
+eval { $dbi->execute("drop table $table1") };
|
2164
|
2164
|
$dbi->execute($create_table1);
|
2165
|
2165
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
2166
|
2166
|
$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
|
...
|
...
|
@@ -2180,7 +2180,7 @@ eval{DBIx::Custom->connect(dsn => undef)};
|
2180
|
2180
|
like($@, qr/_connect/);
|
2181
|
2181
|
|
2182
|
2182
|
$dbi = DBIx::Custom->connect;
|
2183
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2183
|
+eval { $dbi->execute("drop table $table1") };
|
2184
|
2184
|
$dbi->execute($create_table1);
|
2185
|
2185
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
2186
|
2186
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2},
|
...
|
...
|
@@ -2208,7 +2208,7 @@ eval {$dbi->execute("select * from $table1 {} {= author") };
|
2208
|
2208
|
like($@, qr/Tag not finished/);
|
2209
|
2209
|
|
2210
|
2210
|
$dbi = DBIx::Custom->connect;
|
2211
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2211
|
+eval { $dbi->execute("drop table $table1") };
|
2212
|
2212
|
$dbi->execute($create_table1);
|
2213
|
2213
|
$dbi->register_filter(one => sub { 1 });
|
2214
|
2214
|
$result = $dbi->select(table => $table1);
|
...
|
...
|
@@ -2235,7 +2235,7 @@ is($result->stash->{foo}, 1, 'get and set');
|
2235
|
2235
|
|
2236
|
2236
|
test 'delete_at';
|
2237
|
2237
|
$dbi = DBIx::Custom->connect;
|
2238
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2238
|
+eval { $dbi->execute("drop table $table1") };
|
2239
|
2239
|
$dbi->execute($create_table1_2);
|
2240
|
2240
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
|
2241
|
2241
|
$dbi->delete_at(
|
...
|
...
|
@@ -2255,7 +2255,7 @@ is_deeply($dbi->select(table => $table1)->all, []);
|
2255
|
2255
|
|
2256
|
2256
|
test 'insert_at';
|
2257
|
2257
|
$dbi = DBIx::Custom->connect;
|
2258
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2258
|
+eval { $dbi->execute("drop table $table1") };
|
2259
|
2259
|
$dbi->execute($create_table1_2);
|
2260
|
2260
|
$dbi->insert_at(
|
2261
|
2261
|
primary_key => [$key1, $key2],
|
...
|
...
|
@@ -2291,7 +2291,7 @@ eval {
|
2291
|
2291
|
like($@, qr/must be/);
|
2292
|
2292
|
|
2293
|
2293
|
$dbi = DBIx::Custom->connect;
|
2294
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2294
|
+eval { $dbi->execute("drop table $table1") };
|
2295
|
2295
|
$dbi->execute($create_table1_2);
|
2296
|
2296
|
$dbi->insert_at(
|
2297
|
2297
|
{$key3 => 3},
|
...
|
...
|
@@ -2305,7 +2305,7 @@ is($dbi->select(table => $table1)->one->{$key3}, 3);
|
2305
|
2305
|
|
2306
|
2306
|
test 'update_at';
|
2307
|
2307
|
$dbi = DBIx::Custom->connect;
|
2308
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2308
|
+eval { $dbi->execute("drop table $table1") };
|
2309
|
2309
|
$dbi->execute($create_table1_2);
|
2310
|
2310
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
|
2311
|
2311
|
$dbi->update_at(
|
...
|
...
|
@@ -2331,7 +2331,7 @@ is($dbi->select(table => $table1)->one->{$key2}, 2);
|
2331
|
2331
|
is($dbi->select(table => $table1)->one->{$key3}, 4);
|
2332
|
2332
|
|
2333
|
2333
|
$dbi = DBIx::Custom->connect;
|
2334
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2334
|
+eval { $dbi->execute("drop table $table1") };
|
2335
|
2335
|
$dbi->execute($create_table1_2);
|
2336
|
2336
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
|
2337
|
2337
|
$dbi->update_at(
|
...
|
...
|
@@ -2346,7 +2346,7 @@ is($dbi->select(table => $table1)->one->{$key3}, 4);
|
2346
|
2346
|
|
2347
|
2347
|
test 'select_at';
|
2348
|
2348
|
$dbi = DBIx::Custom->connect;
|
2349
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2349
|
+eval { $dbi->execute("drop table $table1") };
|
2350
|
2350
|
$dbi->execute($create_table1_2);
|
2351
|
2351
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
|
2352
|
2352
|
$result = $dbi->select_at(
|
...
|
...
|
@@ -2428,9 +2428,9 @@ $model = $dbi->model($table1);
|
2428
|
2428
|
|
2429
|
2429
|
test 'model delete_at';
|
2430
|
2430
|
$dbi = MyDBI6->connect;
|
2431
|
|
-eval { $dbi->execute('drop table $table1') };
|
2432
|
|
-eval { $dbi->execute('drop table $table2') };
|
2433
|
|
-eval { $dbi->execute('drop table $table3') };
|
|
2431
|
+eval { $dbi->execute("drop table $table1") };
|
|
2432
|
+eval { $dbi->execute("drop table $table2") };
|
|
2433
|
+eval { $dbi->execute("drop table $table3") };
|
2434
|
2434
|
$dbi->execute($create_table1_2);
|
2435
|
2435
|
$dbi->execute($create_table2_2);
|
2436
|
2436
|
$dbi->execute($create_table3);
|
...
|
...
|
@@ -2446,7 +2446,7 @@ is_deeply($dbi->select(table => $table3)->all, []);
|
2446
|
2446
|
|
2447
|
2447
|
test 'model insert_at';
|
2448
|
2448
|
$dbi = MyDBI6->connect;
|
2449
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2449
|
+eval { $dbi->execute("drop table $table1") };
|
2450
|
2450
|
$dbi->execute($create_table1_2);
|
2451
|
2451
|
$dbi->model($table1)->insert_at(
|
2452
|
2452
|
where => [1, 2],
|
...
|
...
|
@@ -2460,7 +2460,7 @@ is($row->{$key3}, 3);
|
2460
|
2460
|
|
2461
|
2461
|
test 'model update_at';
|
2462
|
2462
|
$dbi = MyDBI6->connect;
|
2463
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2463
|
+eval { $dbi->execute("drop table $table1") };
|
2464
|
2464
|
$dbi->execute($create_table1_2);
|
2465
|
2465
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
|
2466
|
2466
|
$dbi->model($table1)->update_at(
|
...
|
...
|
@@ -2475,7 +2475,7 @@ is($row->{$key3}, 4);
|
2475
|
2475
|
|
2476
|
2476
|
test 'model select_at';
|
2477
|
2477
|
$dbi = MyDBI6->connect;
|
2478
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2478
|
+eval { $dbi->execute("drop table $table1") };
|
2479
|
2479
|
$dbi->execute($create_table1_2);
|
2480
|
2480
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
|
2481
|
2481
|
$result = $dbi->model($table1)->select_at(where => [1, 2]);
|
...
|
...
|
@@ -2487,8 +2487,8 @@ is($row->{$key3}, 3);
|
2487
|
2487
|
|
2488
|
2488
|
test 'mycolumn and column';
|
2489
|
2489
|
$dbi = MyDBI7->connect;
|
2490
|
|
-eval { $dbi->execute('drop table $table1') };
|
2491
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
2490
|
+eval { $dbi->execute("drop table $table1") };
|
|
2491
|
+eval { $dbi->execute("drop table $table2") };
|
2492
|
2492
|
$dbi->execute($create_table1);
|
2493
|
2493
|
$dbi->execute($create_table2);
|
2494
|
2494
|
$dbi->separator('__');
|
...
|
...
|
@@ -2498,14 +2498,14 @@ $dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 3});
|
2498
|
2498
|
$model = $dbi->model($table1);
|
2499
|
2499
|
$result = $model->select(
|
2500
|
2500
|
column => [$model->mycolumn, $model->column($table2)],
|
2501
|
|
- where => {'$table1.$key1' => 1}
|
|
2501
|
+ where => {"$table1.$key1" => 1}
|
2502
|
2502
|
);
|
2503
|
2503
|
is_deeply($result->one,
|
2504
|
2504
|
{$key1 => 1, $key2 => 2, "${table2}__$key1" => 1, "${table2}__$key3" => 3});
|
2505
|
2505
|
|
2506
|
2506
|
test 'insert_param';
|
2507
|
2507
|
$dbi = DBIx::Custom->connect;
|
2508
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2508
|
+eval { $dbi->execute("drop table $table1") };
|
2509
|
2509
|
$dbi->execute($create_table1_2);
|
2510
|
2510
|
$param = {$key1 => 1, $key2 => 2};
|
2511
|
2511
|
$insert_param = $dbi->insert_param($param);
|
...
|
...
|
@@ -2517,7 +2517,7 @@ is($dbi->select(table => $table1)->one->{$key1}, 1);
|
2517
|
2517
|
is($dbi->select(table => $table1)->one->{$key2}, 2);
|
2518
|
2518
|
|
2519
|
2519
|
$dbi = DBIx::Custom->connect;
|
2520
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2520
|
+eval { $dbi->execute("drop table $table1") };
|
2521
|
2521
|
$dbi->execute($create_table1_2);
|
2522
|
2522
|
$param = {$key1 => 1, $key2 => 2};
|
2523
|
2523
|
$insert_param = $dbi->insert_param($param);
|
...
|
...
|
@@ -2533,8 +2533,8 @@ like($@, qr/not safety/);
|
2533
|
2533
|
|
2534
|
2534
|
test 'mycolumn';
|
2535
|
2535
|
$dbi = MyDBI8->connect;
|
2536
|
|
-eval { $dbi->execute('drop table $table1') };
|
2537
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
2536
|
+eval { $dbi->execute("drop table $table1") };
|
|
2537
|
+eval { $dbi->execute("drop table $table2") };
|
2538
|
2538
|
$dbi->execute($create_table1);
|
2539
|
2539
|
$dbi->execute($create_table2);
|
2540
|
2540
|
$dbi->setup_model;
|
...
|
...
|
@@ -2557,7 +2557,7 @@ $result = $model->select_at(
|
2557
|
2557
|
]
|
2558
|
2558
|
);
|
2559
|
2559
|
is_deeply($result->one,
|
2560
|
|
- {$key1 => 1, '$table2.$key1' => 1});
|
|
2560
|
+ {$key1 => 1, "$table2.$key1" => 1});
|
2561
|
2561
|
$result = $model->select_at(
|
2562
|
2562
|
column => [
|
2563
|
2563
|
$model->mycolumn([$key1]),
|
...
|
...
|
@@ -2565,7 +2565,7 @@ $result = $model->select_at(
|
2565
|
2565
|
]
|
2566
|
2566
|
);
|
2567
|
2567
|
is_deeply($result->one,
|
2568
|
|
- {$key1 => 1, '$table2.$key1' => 1});
|
|
2568
|
+ {$key1 => 1, "$table2.$key1" => 1});
|
2569
|
2569
|
|
2570
|
2570
|
$result = $model->select_at(
|
2571
|
2571
|
column => [
|
...
|
...
|
@@ -2574,7 +2574,7 @@ $result = $model->select_at(
|
2574
|
2574
|
]
|
2575
|
2575
|
);
|
2576
|
2576
|
is_deeply($result->one,
|
2577
|
|
- {$key1 => 1, '$table2.$key1' => 1});
|
|
2577
|
+ {$key1 => 1, "$table2.$key1" => 1});
|
2578
|
2578
|
|
2579
|
2579
|
$result = $model->select_at(
|
2580
|
2580
|
column => [
|
...
|
...
|
@@ -2583,7 +2583,7 @@ $result = $model->select_at(
|
2583
|
2583
|
]
|
2584
|
2584
|
);
|
2585
|
2585
|
is_deeply($result->one,
|
2586
|
|
- {$key1 => 1, '$table2.$key1' => 1});
|
|
2586
|
+ {$key1 => 1, "$table2.$key1" => 1});
|
2587
|
2587
|
|
2588
|
2588
|
test 'merge_param';
|
2589
|
2589
|
$dbi = DBIx::Custom->new;
|
...
|
...
|
@@ -2604,27 +2604,27 @@ is_deeply($param, {$key1 => [1, 2, 3, 4], $key2 => [1, 2, 3], $key3 => [1, 2, 3]
|
2604
|
2604
|
|
2605
|
2605
|
test 'select() param option';
|
2606
|
2606
|
$dbi = DBIx::Custom->connect;
|
2607
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2607
|
+eval { $dbi->execute("drop table $table1") };
|
2608
|
2608
|
$dbi->execute($create_table1);
|
2609
|
2609
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
2610
|
2610
|
$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
|
2611
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
2611
|
+eval { $dbi->execute("drop table $table2") };
|
2612
|
2612
|
$dbi->execute($create_table2);
|
2613
|
2613
|
$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 4});
|
2614
|
2614
|
$dbi->insert(table => $table2, param => {$key1 => 2, $key3 => 5});
|
2615
|
2615
|
$rows = $dbi->select(
|
2616
|
2616
|
table => $table1,
|
2617
|
2617
|
column => "$table1.$key1 as ${table1}_$key1, $key2, $key3",
|
2618
|
|
- where => {'$table1.$key2' => 3},
|
|
2618
|
+ where => {"$table1.$key2" => 3},
|
2619
|
2619
|
join => ["inner join (select * from $table2 where {= $table2.$key3})" .
|
2620
|
2620
|
" as $table2 on $table1.$key1 = $table2.$key1"],
|
2621
|
|
- param => {'$table2.$key3' => 5}
|
|
2621
|
+ param => {"$table2.$key3" => 5}
|
2622
|
2622
|
)->all;
|
2623
|
2623
|
is_deeply($rows, [{"${table1}_$key1" => 2, $key2 => 3, $key3 => 5}]);
|
2624
|
2624
|
|
2625
|
2625
|
test 'select() string where';
|
2626
|
2626
|
$dbi = DBIx::Custom->connect;
|
2627
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2627
|
+eval { $dbi->execute("drop table $table1") };
|
2628
|
2628
|
$dbi->execute($create_table1);
|
2629
|
2629
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
2630
|
2630
|
$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
|
...
|
...
|
@@ -2636,7 +2636,7 @@ $rows = $dbi->select(
|
2636
|
2636
|
is_deeply($rows, [{$key1 => 1, $key2 => 2}]);
|
2637
|
2637
|
|
2638
|
2638
|
$dbi = DBIx::Custom->connect;
|
2639
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2639
|
+eval { $dbi->execute("drop table $table1") };
|
2640
|
2640
|
$dbi->execute($create_table1);
|
2641
|
2641
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
2642
|
2642
|
$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
|
...
|
...
|
@@ -2651,7 +2651,7 @@ is_deeply($rows, [{$key1 => 1, $key2 => 2}]);
|
2651
|
2651
|
|
2652
|
2652
|
test 'delete() string where';
|
2653
|
2653
|
$dbi = DBIx::Custom->connect;
|
2654
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2654
|
+eval { $dbi->execute("drop table $table1") };
|
2655
|
2655
|
$dbi->execute($create_table1);
|
2656
|
2656
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
2657
|
2657
|
$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
|
...
|
...
|
@@ -2664,7 +2664,7 @@ $rows = $dbi->select(table => $table1)->all;
|
2664
|
2664
|
is_deeply($rows, [{$key1 => 2, $key2 => 3}]);
|
2665
|
2665
|
|
2666
|
2666
|
$dbi = DBIx::Custom->connect;
|
2667
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2667
|
+eval { $dbi->execute("drop table $table1") };
|
2668
|
2668
|
$dbi->execute($create_table1);
|
2669
|
2669
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
2670
|
2670
|
$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
|
...
|
...
|
@@ -2681,7 +2681,7 @@ is_deeply($rows, [{$key1 => 2, $key2 => 3}]);
|
2681
|
2681
|
|
2682
|
2682
|
test 'update() string where';
|
2683
|
2683
|
$dbi = DBIx::Custom->connect;
|
2684
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2684
|
+eval { $dbi->execute("drop table $table1") };
|
2685
|
2685
|
$dbi->execute($create_table1);
|
2686
|
2686
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
2687
|
2687
|
$dbi->update(
|
...
|
...
|
@@ -2694,7 +2694,7 @@ $rows = $dbi->select(table => $table1)->all;
|
2694
|
2694
|
is_deeply($rows, [{$key1 => 5, $key2 => 2}]);
|
2695
|
2695
|
|
2696
|
2696
|
$dbi = DBIx::Custom->connect;
|
2697
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2697
|
+eval { $dbi->execute("drop table $table1") };
|
2698
|
2698
|
$dbi->execute($create_table1);
|
2699
|
2699
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
2700
|
2700
|
$dbi->update(
|
...
|
...
|
@@ -2710,7 +2710,7 @@ is_deeply($rows, [{$key1 => 5, $key2 => 2}]);
|
2710
|
2710
|
|
2711
|
2711
|
test 'insert id and primary_key option';
|
2712
|
2712
|
$dbi = DBIx::Custom->connect;
|
2713
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2713
|
+eval { $dbi->execute("drop table $table1") };
|
2714
|
2714
|
$dbi->execute($create_table1_2);
|
2715
|
2715
|
$dbi->insert(
|
2716
|
2716
|
primary_key => [$key1, $key2],
|
...
|
...
|
@@ -2735,7 +2735,7 @@ is($dbi->select(table => $table1)->one->{$key2}, 2);
|
2735
|
2735
|
is($dbi->select(table => $table1)->one->{$key3}, 3);
|
2736
|
2736
|
|
2737
|
2737
|
$dbi = DBIx::Custom->connect;
|
2738
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2738
|
+eval { $dbi->execute("drop table $table1") };
|
2739
|
2739
|
$dbi->execute($create_table1_2);
|
2740
|
2740
|
$dbi->insert(
|
2741
|
2741
|
{$key3 => 3},
|
...
|
...
|
@@ -2749,7 +2749,7 @@ is($dbi->select(table => $table1)->one->{$key3}, 3);
|
2749
|
2749
|
|
2750
|
2750
|
test 'model insert id and primary_key option';
|
2751
|
2751
|
$dbi = MyDBI6->connect;
|
2752
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2752
|
+eval { $dbi->execute("drop table $table1") };
|
2753
|
2753
|
$dbi->execute($create_table1_2);
|
2754
|
2754
|
$dbi->model($table1)->insert(
|
2755
|
2755
|
id => [1, 2],
|
...
|
...
|
@@ -2762,7 +2762,7 @@ is($row->{$key2}, 2);
|
2762
|
2762
|
is($row->{$key3}, 3);
|
2763
|
2763
|
|
2764
|
2764
|
$dbi = MyDBI6->connect;
|
2765
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2765
|
+eval { $dbi->execute("drop table $table1") };
|
2766
|
2766
|
$dbi->execute($create_table1_2);
|
2767
|
2767
|
$dbi->model($table1)->insert(
|
2768
|
2768
|
{$key3 => 3},
|
...
|
...
|
@@ -2776,7 +2776,7 @@ is($row->{$key3}, 3);
|
2776
|
2776
|
|
2777
|
2777
|
test 'update and id option';
|
2778
|
2778
|
$dbi = DBIx::Custom->connect;
|
2779
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2779
|
+eval { $dbi->execute("drop table $table1") };
|
2780
|
2780
|
$dbi->execute($create_table1_2);
|
2781
|
2781
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
|
2782
|
2782
|
$dbi->update(
|
...
|
...
|
@@ -2802,7 +2802,7 @@ is($dbi->select(table => $table1)->one->{$key2}, 2);
|
2802
|
2802
|
is($dbi->select(table => $table1)->one->{$key3}, 4);
|
2803
|
2803
|
|
2804
|
2804
|
$dbi = DBIx::Custom->connect;
|
2805
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2805
|
+eval { $dbi->execute("drop table $table1") };
|
2806
|
2806
|
$dbi->execute($create_table1_2);
|
2807
|
2807
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
|
2808
|
2808
|
$dbi->update(
|
...
|
...
|
@@ -2818,7 +2818,7 @@ is($dbi->select(table => $table1)->one->{$key3}, 4);
|
2818
|
2818
|
|
2819
|
2819
|
test 'model update and id option';
|
2820
|
2820
|
$dbi = MyDBI6->connect;
|
2821
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2821
|
+eval { $dbi->execute("drop table $table1") };
|
2822
|
2822
|
$dbi->execute($create_table1_2);
|
2823
|
2823
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
|
2824
|
2824
|
$dbi->model($table1)->update(
|
...
|
...
|
@@ -2834,7 +2834,7 @@ is($row->{$key3}, 4);
|
2834
|
2834
|
|
2835
|
2835
|
test 'delete and id option';
|
2836
|
2836
|
$dbi = DBIx::Custom->connect;
|
2837
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2837
|
+eval { $dbi->execute("drop table $table1") };
|
2838
|
2838
|
$dbi->execute($create_table1_2);
|
2839
|
2839
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
|
2840
|
2840
|
$dbi->delete(
|
...
|
...
|
@@ -2855,9 +2855,9 @@ is_deeply($dbi->select(table => $table1)->all, []);
|
2855
|
2855
|
|
2856
|
2856
|
test 'model delete and id option';
|
2857
|
2857
|
$dbi = MyDBI6->connect;
|
2858
|
|
-eval { $dbi->execute('drop table $table1') };
|
2859
|
|
-eval { $dbi->execute('drop table $table2') };
|
2860
|
|
-eval { $dbi->execute('drop table $table3') };
|
|
2858
|
+eval { $dbi->execute("drop table $table1") };
|
|
2859
|
+eval { $dbi->execute("drop table $table2") };
|
|
2860
|
+eval { $dbi->execute("drop table $table3") };
|
2861
|
2861
|
$dbi->execute($create_table1_2);
|
2862
|
2862
|
$dbi->execute($create_table2_2);
|
2863
|
2863
|
$dbi->execute($create_table3);
|
...
|
...
|
@@ -2874,7 +2874,7 @@ is_deeply($dbi->select(table => $table3)->all, []);
|
2874
|
2874
|
|
2875
|
2875
|
test 'select and id option';
|
2876
|
2876
|
$dbi = DBIx::Custom->connect;
|
2877
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2877
|
+eval { $dbi->execute("drop table $table1") };
|
2878
|
2878
|
$dbi->execute($create_table1_2);
|
2879
|
2879
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
|
2880
|
2880
|
$result = $dbi->select(
|
...
|
...
|
@@ -2914,7 +2914,7 @@ is($row->{$key3}, 3);
|
2914
|
2914
|
|
2915
|
2915
|
test 'model select_at';
|
2916
|
2916
|
$dbi = MyDBI6->connect;
|
2917
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
2917
|
+eval { $dbi->execute("drop table $table1") };
|
2918
|
2918
|
$dbi->execute($create_table1_2);
|
2919
|
2919
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
|
2920
|
2920
|
$result = $dbi->model($table1)->select(id => [1, 2]);
|
...
|
...
|
@@ -2925,8 +2925,8 @@ is($row->{$key3}, 3);
|
2925
|
2925
|
|
2926
|
2926
|
test 'column separator is default .';
|
2927
|
2927
|
$dbi = MyDBI7->connect;
|
2928
|
|
-eval { $dbi->execute('drop table $table1') };
|
2929
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
2928
|
+eval { $dbi->execute("drop table $table1") };
|
|
2929
|
+eval { $dbi->execute("drop table $table2") };
|
2930
|
2930
|
$dbi->execute($create_table1);
|
2931
|
2931
|
$dbi->execute($create_table2);
|
2932
|
2932
|
$dbi->setup_model;
|
...
|
...
|
@@ -2935,22 +2935,22 @@ $dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 3});
|
2935
|
2935
|
$model = $dbi->model($table1);
|
2936
|
2936
|
$result = $model->select(
|
2937
|
2937
|
column => [$model->column($table2)],
|
2938
|
|
- where => {'$table1.$key1' => 1}
|
|
2938
|
+ where => {"$table1.$key1" => 1}
|
2939
|
2939
|
);
|
2940
|
2940
|
is_deeply($result->one,
|
2941
|
2941
|
{"$table2.$key1" => 1, "$table2.$key3" => 3});
|
2942
|
2942
|
|
2943
|
2943
|
$result = $model->select(
|
2944
|
|
- column => [$model->column($table2 => [qw/$key1 $key3/])],
|
2945
|
|
- where => {'$table1.$key1' => 1}
|
|
2944
|
+ column => [$model->column($table2 => [$key1, $key3])],
|
|
2945
|
+ where => {"$table1.$key1" => 1}
|
2946
|
2946
|
);
|
2947
|
2947
|
is_deeply($result->one,
|
2948
|
2948
|
{"$table2.$key1" => 1, "$table2.$key3" => 3});
|
2949
|
2949
|
|
2950
|
2950
|
test 'separator';
|
2951
|
2951
|
$dbi = DBIx::Custom->connect;
|
2952
|
|
-eval { $dbi->execute('drop table $table1') };
|
2953
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
2952
|
+eval { $dbi->execute("drop table $table1") };
|
|
2953
|
+eval { $dbi->execute("drop table $table2") };
|
2954
|
2954
|
$dbi->execute($create_table1);
|
2955
|
2955
|
$dbi->execute($create_table2);
|
2956
|
2956
|
|
...
|
...
|
@@ -2971,9 +2971,9 @@ $model = $dbi->model($table1);
|
2971
|
2971
|
$result = $model->select(
|
2972
|
2972
|
column => [
|
2973
|
2973
|
$model->mycolumn,
|
2974
|
|
- {$table2 => [qw/$key1 $key3/]}
|
|
2974
|
+ {$table2 => [$key1, $key3]}
|
2975
|
2975
|
],
|
2976
|
|
- where => {'$table1.$key1' => 1}
|
|
2976
|
+ where => {"$table1.$key1" => 1}
|
2977
|
2977
|
);
|
2978
|
2978
|
is_deeply($result->one,
|
2979
|
2979
|
{$key1 => 1, $key2 => 2, "$table2.$key1" => 1, "$table2.$key3" => 3});
|
...
|
...
|
@@ -2984,9 +2984,9 @@ $model = $dbi->model($table1);
|
2984
|
2984
|
$result = $model->select(
|
2985
|
2985
|
column => [
|
2986
|
2986
|
$model->mycolumn,
|
2987
|
|
- {$table2 => [qw/$key1 $key3/]}
|
|
2987
|
+ {$table2 => [$key1, $key3]}
|
2988
|
2988
|
],
|
2989
|
|
- where => {'$table1.$key1' => 1}
|
|
2989
|
+ where => {"$table1.$key1" => 1}
|
2990
|
2990
|
);
|
2991
|
2991
|
is_deeply($result->one,
|
2992
|
2992
|
{$key1 => 1, $key2 => 2, "${table2}__$key1" => 1, "${table2}__$key3" => 3});
|
...
|
...
|
@@ -2997,9 +2997,9 @@ $model = $dbi->model($table1);
|
2997
|
2997
|
$result = $model->select(
|
2998
|
2998
|
column => [
|
2999
|
2999
|
$model->mycolumn,
|
3000
|
|
- {$table2 => [qw/$key1 $key3/]}
|
|
3000
|
+ {$table2 => [$key1, $key3]}
|
3001
|
3001
|
],
|
3002
|
|
- where => {'$table1.$key1' => 1}
|
|
3002
|
+ where => {"$table1.$key1" => 1}
|
3003
|
3003
|
);
|
3004
|
3004
|
is_deeply($result->one,
|
3005
|
3005
|
{$key1 => 1, $key2 => 2, "$table2-$key1" => 1, "$table2-$key3" => 3});
|
...
|
...
|
@@ -3008,8 +3008,8 @@ is_deeply($model2->select->one, {$key1 => 1, $key3 => 3});
|
3008
|
3008
|
|
3009
|
3009
|
test 'filter_off';
|
3010
|
3010
|
$dbi = DBIx::Custom->connect;
|
3011
|
|
-eval { $dbi->execute('drop table $table1') };
|
3012
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
3011
|
+eval { $dbi->execute("drop table $table1") };
|
|
3012
|
+eval { $dbi->execute("drop table $table2") };
|
3013
|
3013
|
$dbi->execute($create_table1);
|
3014
|
3014
|
$dbi->execute($create_table2);
|
3015
|
3015
|
|
...
|
...
|
@@ -3034,78 +3034,78 @@ ok($dbi->can('available_datatype'));
|
3034
|
3034
|
|
3035
|
3035
|
test 'select prefix option';
|
3036
|
3036
|
$dbi = DBIx::Custom->connect;
|
3037
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3037
|
+eval { $dbi->execute("drop table $table1") };
|
3038
|
3038
|
$dbi->execute($create_table1);
|
3039
|
3039
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
3040
|
|
-$rows = $dbi->select(prefix => '$key1,', column => $key2, table => $table1)->all;
|
|
3040
|
+$rows = $dbi->select(prefix => "$key1,", column => $key2, table => $table1)->all;
|
3041
|
3041
|
is_deeply($rows, [{$key1 => 1, $key2 => 2}], "table");
|
3042
|
3042
|
|
3043
|
3043
|
test 'map_param';
|
3044
|
3044
|
$dbi = DBIx::Custom->connect;
|
3045
|
3045
|
$param = $dbi->map_param(
|
3046
|
3046
|
{id => 1, author => 'Ken', price => 1900},
|
3047
|
|
- id => '$table1.id',
|
3048
|
|
- author => ['$table1.author', sub { '%' . $_[0] . '%' }],
|
3049
|
|
- price => ['$table1.price', {if => sub { $_[0] eq 1900 }}]
|
|
3047
|
+ id => "$table1.id",
|
|
3048
|
+ author => ["$table1.author", sub { '%' . $_[0] . '%' }],
|
|
3049
|
+ price => ["$table1.price", {if => sub { $_[0] eq 1900 }}]
|
3050
|
3050
|
);
|
3051
|
3051
|
is_deeply($param, {"$table1.id" => 1, "$table1.author" => '%Ken%',
|
3052
|
|
- '$table1.price' => 1900});
|
|
3052
|
+ "$table1.price" => 1900});
|
3053
|
3053
|
|
3054
|
3054
|
$param = $dbi->map_param(
|
3055
|
3055
|
{id => 0, author => 0, price => 0},
|
3056
|
|
- id => '$table1.id',
|
3057
|
|
- author => ['$table1.author', sub { '%' . $_[0] . '%' }],
|
3058
|
|
- price => ['$table1.price', sub { '%' . $_[0] . '%' },
|
|
3056
|
+ id => "$table1.id",
|
|
3057
|
+ author => ["$table1.author", sub { '%' . $_[0] . '%' }],
|
|
3058
|
+ price => ["$table1.price", sub { '%' . $_[0] . '%' },
|
3059
|
3059
|
{if => sub { $_[0] eq 0 }}]
|
3060
|
3060
|
);
|
3061
|
3061
|
is_deeply($param, {"$table1.id" => 0, "$table1.author" => '%0%', "$table1.price" => '%0%'});
|
3062
|
3062
|
|
3063
|
3063
|
$param = $dbi->map_param(
|
3064
|
3064
|
{id => '', author => '', price => ''},
|
3065
|
|
- id => '$table1.id',
|
3066
|
|
- author => ['$table1.author', sub { '%' . $_[0] . '%' }],
|
3067
|
|
- price => ['$table1.price', sub { '%' . $_[0] . '%' },
|
|
3065
|
+ id => "$table1.id",
|
|
3066
|
+ author => ["$table1.author", sub { '%' . $_[0] . '%' }],
|
|
3067
|
+ price => ["$table1.price", sub { '%' . $_[0] . '%' },
|
3068
|
3068
|
{if => sub { $_[0] eq 1 }}]
|
3069
|
3069
|
);
|
3070
|
3070
|
is_deeply($param, {});
|
3071
|
3071
|
|
3072
|
3072
|
$param = $dbi->map_param(
|
3073
|
3073
|
{id => undef, author => undef, price => undef},
|
3074
|
|
- id => '$table1.id',
|
3075
|
|
- price => ['$table1.price', {if => 'exists'}]
|
|
3074
|
+ id => "$table1.id",
|
|
3075
|
+ price => ["$table1.price", {if => 'exists'}]
|
3076
|
3076
|
);
|
3077
|
|
-is_deeply($param, {'$table1.price' => undef});
|
|
3077
|
+is_deeply($param, {"$table1.price" => undef});
|
3078
|
3078
|
|
3079
|
3079
|
$param = $dbi->map_param(
|
3080
|
3080
|
{price => 'a'},
|
3081
|
|
- id => ['$table1.id', {if => 'exists'}],
|
3082
|
|
- price => ['$table1.price', sub { '%' . $_[0] }, {if => 'exists'}]
|
|
3081
|
+ id => ["$table1.id", {if => 'exists'}],
|
|
3082
|
+ price => ["$table1.price", sub { '%' . $_[0] }, {if => 'exists'}]
|
3083
|
3083
|
);
|
3084
|
|
-is_deeply($param, {'$table1.price' => '%a'});
|
|
3084
|
+is_deeply($param, {"$table1.price" => '%a'});
|
3085
|
3085
|
|
3086
|
3086
|
test 'order';
|
3087
|
3087
|
$dbi = DBIx::Custom->connect;
|
3088
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3088
|
+eval { $dbi->execute("drop table $table1") };
|
3089
|
3089
|
$dbi->execute($create_table1);
|
3090
|
3090
|
$dbi->insert({$key1 => 1, $key2 => 1}, table => $table1);
|
3091
|
3091
|
$dbi->insert({$key1 => 1, $key2 => 3}, table => $table1);
|
3092
|
3092
|
$dbi->insert({$key1 => 2, $key2 => 2}, table => $table1);
|
3093
|
3093
|
$dbi->insert({$key1 => 2, $key2 => 4}, table => $table1);
|
3094
|
3094
|
my $order = $dbi->order;
|
3095
|
|
-$order->prepend($key1, '$key2 desc');
|
3096
|
|
-$result = $dbi->select(table => $table1, append => "$order");
|
|
3095
|
+$order->prepend($key1, "$key2 desc");
|
|
3096
|
+$result = $dbi->select(table => $table1, append => $order);
|
3097
|
3097
|
is_deeply($result->all, [{$key1 => 1, $key2 => 3}, {$key1 => 1, $key2 => 1},
|
3098
|
3098
|
{$key1 => 2, $key2 => 4}, {$key1 => 2, $key2 => 2}]);
|
3099
|
|
-$order->prepend('$key1 desc');
|
3100
|
|
-$result = $dbi->select(table => $table1, append => "$order");
|
|
3099
|
+$order->prepend("$key1 desc");
|
|
3100
|
+$result = $dbi->select(table => $table1, append => $order);
|
3101
|
3101
|
is_deeply($result->all, [{$key1 => 2, $key2 => 4}, {$key1 => 2, $key2 => 2},
|
3102
|
3102
|
{$key1 => 1, $key2 => 3}, {$key1 => 1, $key2 => 1}]);
|
3103
|
3103
|
|
3104
|
3104
|
$order = $dbi->order;
|
3105
|
|
-$order->prepend(['$table1-$key1'], [qw/$table1-$key2 desc/]);
|
|
3105
|
+$order->prepend(["$table1-$key1"], ["$table1-$key2", 'desc']);
|
3106
|
3106
|
$result = $dbi->select(table => $table1,
|
3107
|
3107
|
column => [[$key1 => "$table1-$key1"], [$key2 => "$table1-$key2"]],
|
3108
|
|
- append => "$order");
|
|
3108
|
+ append => $order);
|
3109
|
3109
|
is_deeply($result->all, [{"$table1-$key1" => 1, "$table1-$key2" => 3},
|
3110
|
3110
|
{"$table1-$key1" => 1, "$table1-$key2" => 1},
|
3111
|
3111
|
{"$table1-$key1" => 2, "$table1-$key2" => 4},
|
...
|
...
|
@@ -3114,7 +3114,7 @@ is_deeply($result->all, [{"$table1-$key1" => 1, "$table1-$key2" => 3},
|
3114
|
3114
|
test 'tag_parse';
|
3115
|
3115
|
$dbi = DBIx::Custom->connect;
|
3116
|
3116
|
$dbi->tag_parse(0);
|
3117
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3117
|
+eval { $dbi->execute("drop table $table1") };
|
3118
|
3118
|
$dbi->execute($create_table1);
|
3119
|
3119
|
$dbi->insert({$key1 => 1, $key2 => 1}, table => $table1);
|
3120
|
3120
|
eval {$dbi->execute("select * from $table1 where {= $key1}", {$key1 => 1})};
|
...
|
...
|
@@ -3122,9 +3122,9 @@ ok($@);
|
3122
|
3122
|
|
3123
|
3123
|
test 'last_sql';
|
3124
|
3124
|
$dbi = DBIx::Custom->connect;
|
3125
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3125
|
+eval { $dbi->execute("drop table $table1") };
|
3126
|
3126
|
$dbi->execute($create_table1);
|
3127
|
|
-$dbi->execute('select * from $table1');
|
|
3127
|
+$dbi->execute("select * from $table1");
|
3128
|
3128
|
is($dbi->last_sql, "select * from $table1;");
|
3129
|
3129
|
|
3130
|
3130
|
eval{$dbi->execute("aaa")};
|
...
|
...
|
@@ -3132,13 +3132,13 @@ is($dbi->last_sql, 'aaa;');
|
3132
|
3132
|
|
3133
|
3133
|
test 'DBIx::Custom header';
|
3134
|
3134
|
$dbi = DBIx::Custom->connect;
|
3135
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3135
|
+eval { $dbi->execute("drop table $table1") };
|
3136
|
3136
|
$dbi->execute($create_table1);
|
3137
|
3137
|
$result = $dbi->execute("select $key1 as h1, $key2 as h2 from $table1");
|
3138
|
3138
|
is_deeply($result->header, [qw/h1 h2/]);
|
3139
|
3139
|
|
3140
|
3140
|
test 'Named placeholder :name(operater) syntax';
|
3141
|
|
-$dbi->execute('drop table $table1');
|
|
3141
|
+$dbi->execute("drop table $table1");
|
3142
|
3142
|
$dbi->execute($create_table1_2);
|
3143
|
3143
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
|
3144
|
3144
|
$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
|
...
|
...
|
@@ -3162,13 +3162,13 @@ $source = "select * from $table1 where :$table1.${key1}{=} and :$table1.${key2}{
|
3162
|
3162
|
$result = $dbi->execute(
|
3163
|
3163
|
$source,
|
3164
|
3164
|
param => {"$table1.$key1" => 1, "$table1.$key2" => 1},
|
3165
|
|
- filter => {'$table1.$key2' => sub { $_[0] * 2 }}
|
|
3165
|
+ filter => {"$table1.$key2" => sub { $_[0] * 2 }}
|
3166
|
3166
|
);
|
3167
|
3167
|
$rows = $result->all;
|
3168
|
3168
|
is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}]);
|
3169
|
3169
|
|
3170
|
3170
|
test 'high perfomance way';
|
3171
|
|
-$dbi->execute('drop table $table1');
|
|
3171
|
+$dbi->execute("drop table $table1");
|
3172
|
3172
|
$dbi->execute($create_table1_highperformance);
|
3173
|
3173
|
$rows = [
|
3174
|
3174
|
{$key7 => 1, $key6 => 2, $key5 => 3, $key4 => 4, $key3 => 5, $key2 => 6, $key1 => 7},
|
...
|
...
|
@@ -3188,7 +3188,7 @@ $rows = [
|
3188
|
3188
|
);
|
3189
|
3189
|
}
|
3190
|
3190
|
|
3191
|
|
-$dbi->execute('drop table $table1');
|
|
3191
|
+$dbi->execute("drop table $table1");
|
3192
|
3192
|
$dbi->execute($create_table1_highperformance);
|
3193
|
3193
|
$rows = [
|
3194
|
3194
|
{$key7 => 1, $key6 => 2, $key5 => 3, $key4 => 4, $key3 => 5, $key2 => 6, $key1 => 7},
|
...
|
...
|
@@ -3212,7 +3212,7 @@ $rows = [
|
3212
|
3212
|
|
3213
|
3213
|
test 'result';
|
3214
|
3214
|
$dbi = DBIx::Custom->connect;
|
3215
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3215
|
+eval { $dbi->execute("drop table $table1") };
|
3216
|
3216
|
$dbi->execute($create_table1);
|
3217
|
3217
|
$dbi->insert({$key1 => 1, $key2 => 2}, table => $table1);
|
3218
|
3218
|
$dbi->insert({$key1 => 3, $key2 => 4}, table => $table1);
|
...
|
...
|
@@ -3232,7 +3232,7 @@ while (my $row = $result->fetch_hash) {
|
3232
|
3232
|
is_deeply(\@rows, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}]);
|
3233
|
3233
|
|
3234
|
3234
|
$dbi = DBIx::Custom->connect;
|
3235
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3235
|
+eval { $dbi->execute("drop table $table1") };
|
3236
|
3236
|
$dbi->execute($create_table1);
|
3237
|
3237
|
$dbi->insert({$key1 => 1, $key2 => 2}, table => $table1);
|
3238
|
3238
|
$dbi->insert({$key1 => 3, $key2 => 4}, table => $table1);
|
...
|
...
|
@@ -3403,14 +3403,14 @@ like($@, qr/unexpected "{"/, "error : 2");
|
3403
|
3403
|
|
3404
|
3404
|
test 'select() wrap option';
|
3405
|
3405
|
$dbi = DBIx::Custom->connect;
|
3406
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3406
|
+eval { $dbi->execute("drop table $table1") };
|
3407
|
3407
|
$dbi->execute($create_table1);
|
3408
|
3408
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
3409
|
3409
|
$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
|
3410
|
3410
|
$rows = $dbi->select(
|
3411
|
3411
|
table => $table1,
|
3412
|
3412
|
column => $key1,
|
3413
|
|
- wrap => ["select * from (', ') as t where $key1 = 1"]
|
|
3413
|
+ wrap => ["select * from (", ") as t where $key1 = 1"]
|
3414
|
3414
|
)->all;
|
3415
|
3415
|
is_deeply($rows, [{$key1 => 1}]);
|
3416
|
3416
|
|
...
|
...
|
@@ -3425,7 +3425,7 @@ like($@, qr/array/);
|
3425
|
3425
|
|
3426
|
3426
|
test 'select() sqlfilter option';
|
3427
|
3427
|
$dbi = DBIx::Custom->connect;
|
3428
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3428
|
+eval { $dbi->execute("drop table $table1") };
|
3429
|
3429
|
$dbi->execute($create_table1);
|
3430
|
3430
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
3431
|
3431
|
$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
|
...
|
...
|
@@ -3442,18 +3442,18 @@ is_deeply($rows, [{$key1 => 1}]);
|
3442
|
3442
|
|
3443
|
3443
|
test 'dbi method from model';
|
3444
|
3444
|
$dbi = MyDBI9->connect;
|
3445
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3445
|
+eval { $dbi->execute("drop table $table1") };
|
3446
|
3446
|
$dbi->execute($create_table1);
|
3447
|
3447
|
$dbi->setup_model;
|
3448
|
3448
|
$model = $dbi->model($table1);
|
3449
|
|
-eval{$model->execute('select * from $table1')};
|
|
3449
|
+eval{$model->execute("select * from $table1")};
|
3450
|
3450
|
ok(!$@);
|
3451
|
3451
|
|
3452
|
3452
|
test 'column table option';
|
3453
|
3453
|
$dbi = MyDBI9->connect;
|
3454
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3454
|
+eval { $dbi->execute("drop table $table1") };
|
3455
|
3455
|
$dbi->execute($create_table1);
|
3456
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
3456
|
+eval { $dbi->execute("drop table $table2") };
|
3457
|
3457
|
$dbi->execute($create_table2);
|
3458
|
3458
|
$dbi->setup_model;
|
3459
|
3459
|
$dbi->execute("insert into $table1 ($key1, $key2) values (1, 2);");
|
...
|
...
|
@@ -3476,7 +3476,7 @@ $result = $model->select(
|
3476
|
3476
|
where => {"$table2_alias.$key3" => 4}
|
3477
|
3477
|
);
|
3478
|
3478
|
is_deeply($result->one,
|
3479
|
|
- {"${table2_alias}__$key1" => 1, "{$table2_alias}__$key3" => 4});
|
|
3479
|
+ {"${table2_alias}__$key1" => 1, "${table2_alias}__$key3" => 4});
|
3480
|
3480
|
|
3481
|
3481
|
$dbi->separator('-');
|
3482
|
3482
|
$result = $model->select(
|
...
|
...
|
@@ -3490,8 +3490,8 @@ is_deeply($result->one,
|
3490
|
3490
|
|
3491
|
3491
|
test 'create_model';
|
3492
|
3492
|
$dbi = DBIx::Custom->connect;
|
3493
|
|
-eval { $dbi->execute('drop table $table1') };
|
3494
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
3493
|
+eval { $dbi->execute("drop table $table1") };
|
|
3494
|
+eval { $dbi->execute("drop table $table2") };
|
3495
|
3495
|
$dbi->execute($create_table1);
|
3496
|
3496
|
$dbi->execute($create_table2);
|
3497
|
3497
|
|
...
|
...
|
@@ -3517,7 +3517,7 @@ $dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 3});
|
3517
|
3517
|
$model = $dbi->model($table1);
|
3518
|
3518
|
$result = $model->select(
|
3519
|
3519
|
column => [$model->mycolumn, $model->column($table2)],
|
3520
|
|
- where => {'$table1.$key1' => 1}
|
|
3520
|
+ where => {"$table1.$key1" => 1}
|
3521
|
3521
|
);
|
3522
|
3522
|
is_deeply($result->one,
|
3523
|
3523
|
{$key1 => 1, $key2 => 2, "$table2.$key1" => 1, "$table2.$key3" => 3});
|
...
|
...
|
@@ -3525,7 +3525,7 @@ is_deeply($model2->select->one, {$key1 => 1, $key3 => 3});
|
3525
|
3525
|
|
3526
|
3526
|
test 'model method';
|
3527
|
3527
|
$dbi = DBIx::Custom->connect;
|
3528
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
3528
|
+eval { $dbi->execute("drop table $table2") };
|
3529
|
3529
|
$dbi->execute($create_table2);
|
3530
|
3530
|
$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 3});
|
3531
|
3531
|
$model = $dbi->create_model(
|
...
|
...
|
@@ -3536,7 +3536,7 @@ is_deeply($model->foo->one, {$key1 => 1, $key3 => 3});
|
3536
|
3536
|
|
3537
|
3537
|
test 'update_param';
|
3538
|
3538
|
$dbi = DBIx::Custom->connect;
|
3539
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3539
|
+eval { $dbi->execute("drop table $table1") };
|
3540
|
3540
|
$dbi->execute($create_table1_2);
|
3541
|
3541
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
|
3542
|
3542
|
$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
|
...
|
...
|
@@ -3556,7 +3556,7 @@ is_deeply($rows, [{$key1 => 1, $key2 => 11, $key3 => 3, $key4 => 4, $key5 => 5},
|
3556
|
3556
|
|
3557
|
3557
|
|
3558
|
3558
|
$dbi = DBIx::Custom->connect;
|
3559
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3559
|
+eval { $dbi->execute("drop table $table1") };
|
3560
|
3560
|
$dbi->execute($create_table1_2);
|
3561
|
3561
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
|
3562
|
3562
|
$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
|
...
|
...
|
@@ -3575,7 +3575,7 @@ is_deeply($rows, [{$key1 => 1, $key2 => 11, $key3 => 33, $key4 => 4, $key5 => 5}
|
3575
|
3575
|
"basic");
|
3576
|
3576
|
|
3577
|
3577
|
$dbi = DBIx::Custom->connect;
|
3578
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3578
|
+eval { $dbi->execute("drop table $table1") };
|
3579
|
3579
|
$dbi->execute($create_table1_2);
|
3580
|
3580
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
|
3581
|
3581
|
$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
|
...
|
...
|
@@ -3600,7 +3600,7 @@ like($@, qr/not safety/);
|
3600
|
3600
|
|
3601
|
3601
|
test 'update_param';
|
3602
|
3602
|
$dbi = DBIx::Custom->connect;
|
3603
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3603
|
+eval { $dbi->execute("drop table $table1") };
|
3604
|
3604
|
$dbi->execute($create_table1_2);
|
3605
|
3605
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
|
3606
|
3606
|
$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
|
...
|
...
|
@@ -3620,14 +3620,14 @@ is_deeply($rows, [{$key1 => 1, $key2 => 11, $key3 => 3, $key4 => 4, $key5 => 5},
|
3620
|
3620
|
|
3621
|
3621
|
test 'join';
|
3622
|
3622
|
$dbi = DBIx::Custom->connect;
|
3623
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3623
|
+eval { $dbi->execute("drop table $table1") };
|
3624
|
3624
|
$dbi->execute($create_table1);
|
3625
|
3625
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
3626
|
3626
|
$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
|
3627
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
3627
|
+eval { $dbi->execute("drop table $table2") };
|
3628
|
3628
|
$dbi->execute($create_table2);
|
3629
|
3629
|
$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 5});
|
3630
|
|
-eval { $dbi->execute('drop table $table3') };
|
|
3630
|
+eval { $dbi->execute("drop table $table3") };
|
3631
|
3631
|
$dbi->execute("create table $table3 ($key3 int, $key4 int);");
|
3632
|
3632
|
$dbi->insert(table => $table3, param => {$key3 => 5, $key4 => 4});
|
3633
|
3633
|
$rows = $dbi->select(
|
...
|
...
|
@@ -3649,7 +3649,7 @@ eval {
|
3649
|
3649
|
$rows = $dbi->select(
|
3650
|
3650
|
table => $table1,
|
3651
|
3651
|
column => "$table1.$key1 as ${table1}_$key1, $table2.$key1 as ${table2}_$key1, $key2, $key3",
|
3652
|
|
- where => {'$table1.$key2' => 2},
|
|
3652
|
+ where => {"$table1.$key2" => 2},
|
3653
|
3653
|
join => {"$table1.$key1" => "$table2.$key1"}
|
3654
|
3654
|
);
|
3655
|
3655
|
};
|
...
|
...
|
@@ -3666,7 +3666,7 @@ is_deeply($rows, [{$key1 => 1, $key2 => 2}]);
|
3666
|
3666
|
$rows = $dbi->select(
|
3667
|
3667
|
column => "$table3.$key4 as ${table3}__$key4",
|
3668
|
3668
|
table => $table1,
|
3669
|
|
- where => {'$table1.$key1' => 1},
|
|
3669
|
+ where => {"$table1.$key1" => 1},
|
3670
|
3670
|
join => ["left outer join $table2 on $table1.$key1 = $table2.$key1",
|
3671
|
3671
|
"left outer join $table3 on $table2.$key3 = $table3.$key3"]
|
3672
|
3672
|
)->all;
|
...
|
...
|
@@ -3675,17 +3675,17 @@ is_deeply($rows, [{"${table3}__$key4" => 4}]);
|
3675
|
3675
|
$rows = $dbi->select(
|
3676
|
3676
|
column => "$table1.$key1 as ${table1}__$key1",
|
3677
|
3677
|
table => $table1,
|
3678
|
|
- where => {'$table3.$key4' => 4},
|
|
3678
|
+ where => {"$table3.$key4" => 4},
|
3679
|
3679
|
join => ["left outer join $table2 on $table1.$key1 = $table2.$key1",
|
3680
|
3680
|
"left outer join $table3 on $table2.$key3 = $table3.$key3"]
|
3681
|
3681
|
)->all;
|
3682
|
3682
|
is_deeply($rows, [{"${table1}__$key1" => 1}]);
|
3683
|
3683
|
|
3684
|
3684
|
$dbi = DBIx::Custom->connect;
|
3685
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3685
|
+eval { $dbi->execute("drop table $table1") };
|
3686
|
3686
|
$dbi->execute($create_table1);
|
3687
|
3687
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
3688
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
3688
|
+eval { $dbi->execute("drop table $table2") };
|
3689
|
3689
|
$dbi->execute($create_table2);
|
3690
|
3690
|
$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 5});
|
3691
|
3691
|
$rows = $dbi->select(
|
...
|
...
|
@@ -3699,7 +3699,7 @@ is_deeply($rows, [{"${table1}_$key1" => 1, "${table2}_$key1" => 1, $key2 => 2, $
|
3699
|
3699
|
|
3700
|
3700
|
|
3701
|
3701
|
$dbi = DBIx::Custom->connect;
|
3702
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3702
|
+eval { $dbi->execute("drop table $table1") };
|
3703
|
3703
|
$dbi->execute($create_table1);
|
3704
|
3704
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
3705
|
3705
|
$sql = <<"EOS";
|
...
|
...
|
@@ -3720,8 +3720,8 @@ $rows = $dbi->select(
|
3720
|
3720
|
is_deeply($rows, [{"latest_${table1}__$key1" => 1}]);
|
3721
|
3721
|
|
3722
|
3722
|
$dbi = DBIx::Custom->connect;
|
3723
|
|
-eval { $dbi->execute('drop table $table1') };
|
3724
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
3723
|
+eval { $dbi->execute("drop table $table1") };
|
|
3724
|
+eval { $dbi->execute("drop table $table2") };
|
3725
|
3725
|
$dbi->execute($create_table1);
|
3726
|
3726
|
$dbi->execute($create_table2);
|
3727
|
3727
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
...
|
...
|
@@ -3741,7 +3741,7 @@ $result = $dbi->select(
|
3741
|
3741
|
"left outer join $table2 on $table2.$key3 = '4' and $table1.$key1 = $table2.$key1"
|
3742
|
3742
|
]
|
3743
|
3743
|
);
|
3744
|
|
-is_deeply($result->all, [{'$table2.$key3' => 4}]);
|
|
3744
|
+is_deeply($result->all, [{"$table2.$key3" => 4}]);
|
3745
|
3745
|
$result = $dbi->select(
|
3746
|
3746
|
table => $table1,
|
3747
|
3747
|
column => [{$table2 => [$key3]}],
|
...
|
...
|
@@ -3749,11 +3749,11 @@ $result = $dbi->select(
|
3749
|
3749
|
"left outer join $table2 on $table1.$key1 = $table2.$key1 and $table2.$key3 = '4'"
|
3750
|
3750
|
]
|
3751
|
3751
|
);
|
3752
|
|
-is_deeply($result->all, [{'$table2.$key3' => 4}]);
|
|
3752
|
+is_deeply($result->all, [{"$table2.$key3" => 4}]);
|
3753
|
3753
|
|
3754
|
3754
|
$dbi = DBIx::Custom->connect;
|
3755
|
|
-eval { $dbi->execute('drop table $table1') };
|
3756
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
3755
|
+eval { $dbi->execute("drop table $table1") };
|
|
3756
|
+eval { $dbi->execute("drop table $table2") };
|
3757
|
3757
|
$dbi->execute($create_table1);
|
3758
|
3758
|
$dbi->execute($create_table2);
|
3759
|
3759
|
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
|
...
|
...
|
@@ -3774,12 +3774,12 @@ is_deeply($result->all, [{"$table2.$key3" => 4}]);
|
3774
|
3774
|
test 'Model class';
|
3775
|
3775
|
use MyDBI1;
|
3776
|
3776
|
$dbi = MyDBI1->connect;
|
3777
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3777
|
+eval { $dbi->execute("drop table $table1") };
|
3778
|
3778
|
$dbi->execute($create_table1);
|
3779
|
3779
|
$model = $dbi->model($table1);
|
3780
|
3780
|
$model->insert({$key1 => 'a', $key2 => 'b'});
|
3781
|
3781
|
is_deeply($model->list->all, [{$key1 => 'a', $key2 => 'b'}], 'basic');
|
3782
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
3782
|
+eval { $dbi->execute("drop table $table2") };
|
3783
|
3783
|
$dbi->execute($create_table2);
|
3784
|
3784
|
$model = $dbi->model($table2);
|
3785
|
3785
|
$model->insert({$key1 => 'a'});
|
...
|
...
|
@@ -3788,20 +3788,20 @@ is($dbi->models->{$table1}, $dbi->model($table1));
|
3788
|
3788
|
is($dbi->models->{$table2}, $dbi->model($table2));
|
3789
|
3789
|
|
3790
|
3790
|
$dbi = MyDBI4->connect;
|
3791
|
|
-eval { $dbi->execute('drop table $table1') };
|
|
3791
|
+eval { $dbi->execute("drop table $table1") };
|
3792
|
3792
|
$dbi->execute($create_table1);
|
3793
|
3793
|
$model = $dbi->model($table1);
|
3794
|
3794
|
$model->insert({$key1 => 'a', $key2 => 'b'});
|
3795
|
3795
|
is_deeply($model->list->all, [{$key1 => 'a', $key2 => 'b'}], 'basic');
|
3796
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
3796
|
+eval { $dbi->execute("drop table $table2") };
|
3797
|
3797
|
$dbi->execute($create_table2);
|
3798
|
3798
|
$model = $dbi->model($table2);
|
3799
|
3799
|
$model->insert({$key1 => 'a'});
|
3800
|
3800
|
is_deeply($model->list->all, [{$key1 => 'a', $key3 => undef}], 'basic');
|
3801
|
3801
|
|
3802
|
3802
|
$dbi = MyDBI5->connect;
|
3803
|
|
-eval { $dbi->execute('drop table $table1') };
|
3804
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
3803
|
+eval { $dbi->execute("drop table $table1") };
|
|
3804
|
+eval { $dbi->execute("drop table $table2") };
|
3805
|
3805
|
$dbi->execute($create_table1);
|
3806
|
3806
|
$dbi->execute($create_table2);
|
3807
|
3807
|
$model = $dbi->model($table2);
|
...
|
...
|
@@ -3828,8 +3828,8 @@ is_deeply($model->columns, [$key1, $key2]);
|
3828
|
3828
|
test 'setup_model';
|
3829
|
3829
|
use MyDBI1;
|
3830
|
3830
|
$dbi = MyDBI1->connect;
|
3831
|
|
-eval { $dbi->execute('drop table $table1') };
|
3832
|
|
-eval { $dbi->execute('drop table $table2') };
|
|
3831
|
+eval { $dbi->execute("drop table $table1") };
|
|
3832
|
+eval { $dbi->execute("drop table $table2") };
|
3833
|
3833
|
|
3834
|
3834
|
$dbi->execute($create_table1);
|
3835
|
3835
|
$dbi->execute($create_table2);
|