00cb5c51d95e0340ad631e087fa6cdcb2f1e81fa
[dbsrgits/SQL-Abstract.git] / t / 22op_value.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use SQL::Abstract;
6 use SQL::Abstract::Test import => [qw/is_same_sql_bind/];
7
8 for my $q ('', '"') {
9 for my $col_btype (0,1) {
10
11   my $sql_maker = SQL::Abstract->new(
12     quote_char => $q,
13     name_sep => $q ? '.' : '',
14     $col_btype ? (bindtype => 'columns') : (),
15   );
16
17   my ($sql, @bind) = $sql_maker->select ('artist', '*', { arr1 => { -value => [1,2] }, arr2 => { '>', { -value => [3,4] } }, field => [5,6] } );
18
19   is_same_sql_bind (
20     $sql,
21     \@bind,
22     "SELECT *
23       FROM ${q}artist${q}
24       WHERE ${q}arr1${q} = ? AND
25             ${q}arr2${q} > ? AND
26             ( ${q}field${q} = ? OR ${q}field${q} = ? )
27     ",
28     [
29       $col_btype
30         ? (
31           [ arr1 => [ 1, 2 ] ],
32           [ arr2 => [ 3, 4 ] ],
33           [ field => 5 ],
34           [ field => 6 ],
35         ) : (
36           [ 1, 2 ],
37           [ 3, 4 ],
38           5,
39           6,
40         )
41     ],
42   );
43 }}
44
45 done_testing;