{regex => qr/^ (?: not \s )? in $/ix, handler => '_where_field_IN'},
{regex => qr/^ ident $/ix, handler => '_where_op_IDENT'},
{regex => qr/^ value $/ix, handler => '_where_op_VALUE'},
+ {regex => qr/^ is (?: \s+ not )? $/ix, handler => '_where_field_IS'},
);
# unaryish operators - key maps to handler
{ regex => qr/^ nest (?: [_\s]? \d+ )? $/xi, handler => '_where_op_NEST' },
{ regex => qr/^ (?: not \s )? bool $/xi, handler => '_where_op_BOOL' },
{ regex => qr/^ ident $/xi, handler => '_where_op_IDENT' },
- { regex => qr/^ value $/ix, handler => '_where_op_VALUE' },
+ { regex => qr/^ value $/xi, handler => '_where_op_VALUE' },
);
#======================================================================
$self->_assert_pass_injection_guard($op);
+ # fixup is_not
+ $op =~ s/^is_not/IS NOT/i;
+
# so that -not_foo works correctly
$op =~ s/^not_/NOT /i;
return ($all_sql, @all_bind);
}
+sub _where_field_IS {
+ my ($self, $k, $op, $v) = @_;
+
+ my ($s) = $self->_SWITCH_refkind($v, {
+ UNDEF => sub {
+ join ' ',
+ $self->_convert($self->_quote($k)),
+ map { $self->_sqlcase($_)} ($op, 'null')
+ },
+ FALLBACK => sub {
+ puke "$op can only take undef as argument";
+ },
+ });
+ $s;
+}
sub _where_field_op_ARRAYREF {
my ($self, $k, $op, $vals) = @_;
},
);
+# check is( not) => undef
+for my $op (qw( is is_not), 'is not' ) {
+ (my $sop = uc $op) =~ s/_/ /gi;
+
+ push @tests, {
+ func => 'where',
+ args => [{ a => { "$_$op" => undef } }],
+ stmt => "WHERE a $sop NULL",
+ stmt_q => "WHERE `a` $sop NULL",
+ bind => [],
+ } for ('', '-'); # with and without -
+}
+
# check single-element inequality ops for no warnings
for my $op ( qw(!= <>) ) {
for my $val (undef, 42) {