From: Matt S Trout Date: Sun, 16 Sep 2018 21:36:15 +0000 (+0000) Subject: fixup operator + empty arrayref handling X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b3cb13e8cefc48d724f02a2363f2b9d7a8e745da;p=scpubgit%2FQ-Branch.git fixup operator + empty arrayref handling --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index fefaf94..2d1a7b1 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -800,9 +800,17 @@ sub _expand_expr_hashpair { . "to say ...{ \$inequality_op => [ -and => \@values ] }... instead)" ; } - return $self->{sqltrue} unless @values; } - return $self->{sqlfalse} unless @values; + unless (@values) { + # try to DWIM on equality operators + my $op = join ' ', split '_', $vk; + return + $op =~ $self->{equality_op} ? $self->{sqlfalse} + : $op =~ $self->{like_op} ? belch("Supplying an empty arrayref to '@{[ uc $op]}' is deprecated") && $self->{sqlfalse} + : $op =~ $self->{inequality_op} ? $self->{sqltrue} + : $op =~ $self->{not_like_op} ? belch("Supplying an empty arrayref to '@{[ uc $op]}' is deprecated") && $self->{sqltrue} + : puke "operator '$op' applied on an empty array (field '$k')"; + } return +{ $logic => [ map $self->_expand_expr_hashpair($k => { $vk => $_ }), @values