return wantarray ? ($sql, @bind) : $sql;
}
+sub _expand_expr {
+ my ($self, $expr, $logic) = @_;
+ if (ref($expr) eq 'HASH' and keys %$expr > 1) {
+ $logic ||= 'and';
+ return +{ "-${logic}" => [
+ map +{ $_ => $expr->{$_} }, sort keys %$expr
+ ] };
+ }
+ return $expr;
+}
sub _recurse_where {
my ($self, $where, $logic) = @_;
+ my $where_exp = $self->_expand_expr($where, $logic);
+
# dispatch on appropriate method according to refkind of $where
- my $method = $self->_METHOD_FOR_refkind("_where", $where);
+ my $method = $self->_METHOD_FOR_refkind("_where", $where_exp);
- my ($sql, @bind) = $self->$method($where, $logic);
+ my ($sql, @bind) = $self->$method($where_exp, $logic);
# DBIx::Class used to call _recurse_where in scalar context
# something else might too...
# special-case NULL
if (! defined $rhs) {
return defined $lhs
- ? $self->_convert($self->_quote($lhs)) . ' IS NULL'
+ ? $self->_where_hashpair_HASHREF($lhs, { -is => undef })
: undef
;
}
sub _where_hashpair_UNDEF {
my ($self, $k, $v) = @_;
$self->_debug("UNDEF($k) means IS NULL");
- my $sql = $self->_quote($k) . $self->_sqlcase(' is null');
- return ($sql);
+ return $self->_where_hashpair_HASHREF($k, { -is => undef });
}
#======================================================================