7 use SQL::Abstract::Test import => ['is_same_sql_bind'];
18 * [scalarref, scalarref]
20 * \["? AND ?", scalar, scalar]
21 * \["1 AND ?", scalar]
22 * \["? AND 2", scalar]
26 my @in_between_tests = (
28 where => { x => { -between => [1, 2] } },
29 stmt => 'WHERE (x BETWEEN ? AND ?)',
31 test => '-between with two placeholders',
34 where => { x => { -between => [\"1", 2] } },
35 stmt => 'WHERE (x BETWEEN 1 AND ?)',
37 test => '-between with one literal sql arg and one placeholder',
40 where => { x => { -between => [1, \"2"] } },
41 stmt => 'WHERE (x BETWEEN ? AND 2)',
43 test => '-between with one placeholder and one literal sql arg',
46 where => { x => { -between => [\'current_date - 1', \'current_date - 0'] } },
47 stmt => 'WHERE (x BETWEEN current_date - 1 AND current_date - 0)',
49 test => '-between with two literal sql arguments',
52 where => { x => { -between => \['? AND ?', 1, 2] } },
53 stmt => 'WHERE (x BETWEEN ? AND ?)',
55 test => '-between with literal sql with placeholders (\["? AND ?", scalar, scalar])',
58 where => { x => { -between => \["'something' AND ?", 2] } },
59 stmt => "WHERE (x BETWEEN 'something' AND ?)",
61 test => '-between with literal sql with one literal arg and one placeholder (\["\'something\' AND ?", scalar])',
64 where => { x => { -between => \["? AND 'something'", 1] } },
65 stmt => "WHERE (x BETWEEN ? AND 'something')",
67 test => '-between with literal sql with one placeholder and one literal arg (\["? AND \'something\'", scalar])',
70 where => { x => { -between => \["'this' AND 'that'"] } },
71 stmt => "WHERE (x BETWEEN 'this' AND 'that')",
73 test => '-between with literal sql with two literal args (\["\'this\' AND \'that\'"])',
77 plan tests => @in_between_tests*3;
79 for my $case (@in_between_tests) {
81 local $TODO = $case->{todo} if $case->{todo};
83 local $Data::Dumper::Terse = 1;
86 local $SIG{__WARN__} = sub { push @w, @_ };
87 my $sql = SQL::Abstract->new ($case->{args} || {});
89 my ($stmt, @bind) = $sql->where($case->{where});
96 || diag "Search term:\n" . Dumper $case->{where};
98 is (@w, 0, $case->{test} || 'No warnings within in-between tests')
99 || diag join "\n", 'Emitted warnings:', @w;