);
} elsif (!defined($rhs)) {
my $null_op = do {
- if ($op eq '=' or $op eq 'LIKE') {
+ if ($op eq '=' or $op eq 'LIKE' or $op eq 'IS') {
'IS NULL'
- } elsif ($op eq '!=') {
+ } elsif ($op eq '!=' or $op eq 'NOT LIKE' or $op eq 'IS NOT') {
'IS NOT NULL'
} else {
die "Can't do undef -> NULL transform for operator ${op}";
stmt_q => 'SELECT * FROM `test` WHERE ( `a` IS NULL AND `b` IS NOT NULL )',
bind => [],
},
+ {
+ func => 'select',
+ args => ['test', '*', { a => { '=' => undef }, b => { -is => undef }, c => { -like => undef } }],
+ stmt => 'SELECT * FROM test WHERE ( a IS NULL AND b IS NULL AND c IS NULL )',
+ stmt_q => 'SELECT * FROM `test` WHERE ( `a` IS NULL AND `b` IS NULL AND `c` IS NULL )',
+ bind => [],
+ },
+ {
+ func => 'select',
+ args => ['test', '*', { a => { '!=' => undef }, b => { -is_not => undef }, c => { -not_like => undef } }],
+ stmt => 'SELECT * FROM test WHERE ( a IS NOT NULL AND b IS NOT NULL AND c IS NOT NULL )',
+ stmt_q => 'SELECT * FROM `test` WHERE ( `a` IS NOT NULL AND `b` IS NOT NULL AND `c` IS NOT NULL )',
+ bind => [],
+ },
+ {
+ func => 'select',
+ args => ['test', '*', { a => { IS => undef }, b => { LIKE => undef } }],
+ stmt => 'SELECT * FROM test WHERE ( a IS NULL AND b IS NULL )',
+ stmt_q => 'SELECT * FROM `test` WHERE ( `a` IS NULL AND `b` IS NULL )',
+ bind => [],
+ },
+ {
+ func => 'select',
+ args => ['test', '*', { a => { 'IS NOT' => undef }, b => { 'NOT LIKE' => undef } }],
+ stmt => 'SELECT * FROM test WHERE ( a IS NOT NULL AND b IS NOT NULL )',
+ stmt_q => 'SELECT * FROM `test` WHERE ( `a` IS NOT NULL AND `b` IS NOT NULL )',
+ bind => [],
+ },
);
for my $t (@tests) {