},
{
func => 'select',
+ args => ['test', '*', { a => { -in => [] }, b => { -not_in => [] } }],
+ stmt => 'SELECT * FROM test WHERE ( 0=1 AND 1=1 )',
+ stmt_q => 'SELECT * FROM `test` WHERE ( 0=1 AND 1=1 )',
+ bind => [],
+ },
+ {
+ func => 'select',
args => ['test', '*', { a => { -in => [42, undef] }, b => { -not_in => [42, undef] } } ],
stmt => 'SELECT * FROM test WHERE ( ( a IN ( ? ) OR a IS NULL ) AND b NOT IN ( ? ) AND b IS NOT NULL )',
stmt_q => 'SELECT * FROM `test` WHERE ( ( `a` IN ( ? ) OR `a` IS NULL ) AND `b` NOT IN ( ? ) AND `b` IS NOT NULL )',
stmt_q => 'SELECT * FROM `test` WHERE ( `a` IS NOT NULL AND `b` IS NOT NULL )',
bind => [],
},
+ {
+ func => 'select',
+ args => ['test', '*', { a => { -in => undef } }],
+ exception_like => qr/Argument passed to the 'IN' operator can not be undefined/,
+ },
);
+# check is( not) => undef
+for my $op ( qw(not is is_not), 'is not' ) {
+ (my $sop = uc $op) =~ s/_/ /gi;
+
+ $sop = 'IS NOT' if $sop eq 'NOT';
+
+ for my $uc (0, 1) {
+ for my $prefix ('', '-') {
+ push @tests, {
+ func => 'where',
+ args => [{ a => { ($prefix . ($uc ? uc $op : lc $op) ) => undef } }],
+ stmt => "WHERE a $sop NULL",
+ stmt_q => "WHERE `a` $sop NULL",
+ bind => [],
+ };
+ }
+ }
+}
+
for my $t (@tests) {
local $"=', ';
.Dumper($t)."Exception was: $@";
}
}
+
is_same_sql_bind(
$stmt,
\@bind,