From: Matt S Trout Date: Tue, 12 Feb 2019 19:39:44 +0000 (+0000) Subject: single fire -nest warning because DBIC expects it, fix an order_by bug X-Git-Tag: v1.90_01~408 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=74156ee902717f09df7ffa18318a99859a30c5a5;p=dbsrgits%2FSQL-Abstract.git single fire -nest warning because DBIC expects it, fix an order_by bug --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index f078dc9..31ed6fb 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -553,6 +553,8 @@ sub _expand_expr { die "notreached"; } +our $Nest_Warning_Emitted = 0; + sub _expand_expr_hashpair { my ($self, $k, $v, $logic) = @_; unless (defined($k) and length($k)) { @@ -569,6 +571,10 @@ sub _expand_expr_hashpair { . "You probably wanted ...-and => [ $k => COND1, $k => COND2 ... ]"; } if ($k eq '-nest') { + belch( + "-nest in search conditions is deprecated, you most probably wanted:\n" + .q|{..., -and => [ \%cond0, \@cond1, \'cond2', \[ 'cond3', [ col => bind ] ], etc. ], ... }| + ) unless $Nest_Warning_Emitted++; return $self->_expand_expr($v); } if ($k eq '-bool') { @@ -1067,7 +1073,8 @@ sub _expand_order_by { } } my @exp = map +(defined($dir) ? { -op => [ $dir => $_ ] } : $_), - map $self->_expand_expr($_, undef, -ident), @to_expand; + map $self->_expand_expr($_, undef, -ident), + map ref($_) eq 'ARRAY' ? @$_ : $_, @to_expand; return (@exp > 1 ? { -op => [ ',', @exp ] } : $exp[0]); }; diff --git a/t/01generate.t b/t/01generate.t index 4c23c48..008c7ca 100644 --- a/t/01generate.t +++ b/t/01generate.t @@ -16,6 +16,11 @@ use SQL::Abstract; # ################# +# DBIx::Class requires a nest warning to be emitted once but the private +# method it overrode to do so no longer exists; here we cancel said warning +# to avoid disturbing the SQLA tests + +$SQL::Abstract::Nest_Warning_Emitted++; my @tests = ( {