From: Matt S Trout Date: Mon, 3 Sep 2018 21:34:47 +0000 (+0000) Subject: hashpair expansion - defaulting to $self->{cmp} X-Git-Tag: v1.90_01~486 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5958869562eeeabbddda78605bd8461fb9f4d060;p=dbsrgits%2FSQL-Abstract.git hashpair expansion - defaulting to $self->{cmp} --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 3327db7..e639428 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -537,15 +537,29 @@ sub where { 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 - ] }; + if (ref($expr) eq 'HASH') { + if (keys %$expr > 1) { + $logic ||= 'and'; + return +{ "-${logic}" => [ + map $self->_expand_expr_hashpair($_ => $expr->{$_}, $logic), + sort keys %$expr + ] }; + } + return $self->_expand_expr_hashpair(%$expr, $logic); } return $expr; } +sub _expand_expr_hashpair { + my ($self, $k, $v, $logic) = @_; + if (!ref($v)) { + if ($k !~ /^-/) { + return +{ $k => { $self->{cmp} => $v } }; + } + } + return { $k => $v }; +} + sub _recurse_where { my ($self, $where, $logic) = @_;