my ($inop, $logic, $nullop) = $op =~ /^NOT/
? (-not_in => AND => { '!=' => undef })
: (-in => OR => undef);
- return $self->_expr_to_dq_ARRAYREF([
- { $k => { $inop => [grep defined, @$rhs] } },
+ if (my @defined = grep defined, @$rhs) {
+ return $self->_expr_to_dq_ARRAYREF([
+ { $k => { $inop => \@defined } },
{ $k => $nullop },
], $logic);
+ } else {
+ return $self->_expr_to_dq_HASHREF({
+ $k => $nullop,
+ });
+ }
}
return $self->_literal_to_dq(
$op =~ /^NOT/ ? $self->{sqltrue} : $self->{sqlfalse}
stmt_q => 'SELECT * FROM `test` WHERE ( ( `a` IN ( ? ) OR `a` IS NULL ) AND `b` NOT IN ( ? ) AND `b` IS NOT NULL )',
bind => [ 42, 42 ],
},
+ {
+ func => 'select',
+ args => ['test', '*', { a => { -in => [undef] }, b => { -not_in => [undef] } } ],
+ stmt => 'SELECT * FROM test WHERE ( a IS NULL AND b IS NOT NULL )',
+ stmt_q => 'SELECT * FROM `test` WHERE ( `a` IS NULL AND `b` IS NOT NULL )',
+ bind => [],
+ },
);
for my $t (@tests) {