From: Matt S Trout Date: Tue, 4 Sep 2018 02:29:14 +0000 (+0000) Subject: arrayref hashpair case X-Git-Tag: v1.90_01~482 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7dbe1183667270f83c19c54d8e9808c72388f2ed;p=dbsrgits%2FSQL-Abstract.git arrayref hashpair case --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 1327193..3078d8e 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -560,6 +560,16 @@ sub _expand_expr_hashpair { if (!ref($v)) { return +{ $k => { $self->{cmp} => $v } }; } + if (ref($v) eq 'ARRAY') { + return $self->{sqlfalse} unless @$v; + $self->_debug("ARRAY($k) means distribute over elements"); + my $this_logic = ( + $v->[0] =~ /^-((?:and|or))$/i + ? ($v = [ @{$v}[1..$#$v] ], $1) + : ($self->{logic} || 'or') + ); + return +{ "-${this_logic}" => [ map $self->_expand_expr({ $k => $_ }, $this_logic), @$v ] }; + } if (my $literal = is_literal_value($v)) { unless (length $k) { belch 'Hash-pairs consisting of an empty string with a literal are deprecated, and will be removed in 2.0: use -and => [ $literal ] instead';