From: Dagfinn Ilmari Mannsåker Date: Mon, 28 Oct 2019 11:08:59 +0000 (+0000) Subject: Fix warning on thing => [ undef, ... ] X-Git-Tag: v2.000000~3^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fq;p=dbsrgits%2FSQL-Abstract.git Fix warning on thing => [ undef, ... ] In passing, change warnings_exist to warnings_like, to catch unexpected warnings. --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 3439e37..30b3ffc 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -1049,7 +1049,7 @@ sub _expand_hashpair_ident { return $self->sqlfalse unless @$v; $self->_debug("ARRAY($k) means distribute over elements"); my $logic = lc( - $v->[0] =~ /^-(and|or)$/i + ($v->[0]||'') =~ /^-(and|or)$/i ? (shift(@{$v = [ @$v ]}), $1) : lc($self->{logic} || 'OR') ); diff --git a/t/02where.t b/t/02where.t index 204a8fd..4c21045 100644 --- a/t/02where.t +++ b/t/02where.t @@ -123,6 +123,14 @@ my @handle_tests = ( { where => { + requestor => [undef, ''], + }, + stmt => " WHERE ( requestor IS NULL OR requestor = ? )", + bind => [''], + }, + + { + where => { priority => [ {'>', 3}, {'<', 1} ], requestor => { '!=', undef }, }, @@ -419,7 +427,7 @@ for my $case (@handle_tests) { my $sql = SQL::Abstract->new; my ($stmt, @bind); lives_ok { - warnings_exist { + warnings_like { ($stmt, @bind) = $sql->where($case->{where}, $case->{order}); } $case->{warns} || []; };