6 use SQL::Abstract::Test import => ['is_same_sql'];
12 args => {logic => 'OR'},
13 stmt => 'SELECT * FROM test WHERE ( a = ? AND b = ? )'
18 stmt => 'SELECT * FROM test WHERE ( a = ? AND b = ? )'
22 args => {case => "upper"},
23 stmt => 'SELECT * FROM test WHERE ( a = ? AND b = ? )'
27 args => {case => "upper", cmp => "="},
28 stmt => 'SELECT * FROM test WHERE ( a = ? AND b = ? )'
32 args => {cmp => "=", logic => 'or'},
33 stmt => 'SELECT * FROM test WHERE ( a = ? AND b = ? )'
37 args => {cmp => "like"},
38 stmt => 'SELECT * FROM test WHERE ( a LIKE ? AND b LIKE ? )'
42 args => {logic => "or", cmp => "like"},
43 stmt => 'SELECT * FROM test WHERE ( a LIKE ? AND b LIKE ? )'
47 args => {case => "lower"},
48 stmt => 'select * from test where ( a = ? and b = ? )'
52 args => {case => "lower", cmp => "="},
53 stmt => 'select * from test where ( a = ? and b = ? )'
57 args => {case => "lower", cmp => "like"},
58 stmt => 'select * from test where ( a like ? and b like ? )'
62 args => {case => "lower", convert => "lower", cmp => "like"},
63 stmt => 'select * from test where ( lower(a) like lower(?) and lower(b) like lower(?) )'
67 args => {convert => "Round"},
68 stmt => 'SELECT * FROM test WHERE ( ROUND(a) = ROUND(?) AND ROUND(b) = ROUND(?) )',
72 args => {convert => "lower"},
73 stmt => 'SELECT * FROM test WHERE ( ( LOWER(ticket) = LOWER(?) ) OR ( LOWER(hostname) = LOWER(?) ) OR ( LOWER(taco) = LOWER(?) ) OR ( LOWER(salami) = LOWER(?) ) )',
74 where => [ { ticket => 11 }, { hostname => 11 }, { taco => 'salad' }, { salami => 'punch' } ],
78 args => {convert => "upper"},
79 stmt => 'SELECT * FROM test WHERE ( ( UPPER(hostname) IN ( UPPER(?), UPPER(?), UPPER(?), UPPER(?) ) AND ( ( UPPER(ticket) = UPPER(?) ) OR ( UPPER(ticket) = UPPER(?) ) OR ( UPPER(ticket) = UPPER(?) ) ) ) OR ( UPPER(tack) BETWEEN UPPER(?) AND UPPER(?) ) OR ( ( ( UPPER(a) = UPPER(?) ) OR ( UPPER(a) = UPPER(?) ) OR ( UPPER(a) = UPPER(?) ) ) AND ( ( UPPER(e) != UPPER(?) ) OR ( UPPER(e) != UPPER(?) ) ) AND UPPER(q) NOT IN ( UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?) ) ) )',
80 where => [ { ticket => [11, 12, 13],
81 hostname => { in => ['ntf', 'avd', 'bvd', '123'] } },
82 { tack => { between => [qw/tick tock/] } },
84 e => { '!=', [qw(f g)] },
85 q => { 'not in', [14..20] } } ],
86 warns => qr/\QA multi-element arrayref as an argument to the inequality op '!=' is technically equivalent to an always-true 1=1/,
91 my $sqla = SQL::Abstract->new($_->{args});
94 $stmt = $sqla->select(
97 $_->{where} || { a => 4, b => 0}
101 is_same_sql($stmt, $_->{stmt});