Commit | Line | Data |
e5360be4 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | use Test::More; |
6 | use Test::Exception; |
7 | use SQL::Abstract::Test import => ['is_same_sql_bind']; |
8 | |
9 | use Data::Dumper; |
10 | use SQL::Abstract; |
11 | |
12 | =begin |
13 | Test -and -or and -nest/-nestX modifiers, assuming the following: |
14 | |
15 | * Modifiers are respected in both hashrefs and arrayrefs (with the obvious limitation of one modifier type per hahsref) |
16 | * Each modifier affects only the immediate element following it |
17 | * In the case of -nestX simply wrap whatever the next element is in a pair of (), regardless of type |
18 | * In the case of -or/-and explicitly setting the logic within a following hashref or arrayref, |
19 | without imposing the logic on any sub-elements of the affected structure |
20 | * Ignore (maybe throw exception?) of the -or/-and modifier if the following element is missing, |
21 | or is of a type other than hash/arrayref |
22 | |
23 | =cut |
24 | |
25 | |
26 | my @handle_tests = (); |
27 | |
a0b42c3e |
28 | plan tests => @handle_tests * 2 + 1; |
29 | ok (1); |
e5360be4 |
30 | |
31 | for my $case (@handle_tests) { |
32 | local $Data::Dumper::Terse = 1; |
33 | my $sql = SQL::Abstract->new; |
34 | my($stmt, @bind); |
35 | lives_ok (sub { |
36 | ($stmt, @bind) = $sql->where($case->{where}, $case->{order}); |
37 | is_same_sql_bind($stmt, \@bind, $case->{stmt}, $case->{bind}) |
38 | || diag "Search term:\n" . Dumper $case->{where}; |
39 | }); |
40 | } |