From: Matt S Trout Date: Wed, 13 Feb 2019 03:01:48 +0000 (+0000) Subject: make the DBIC required warning scoped X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0fc68377a305ab7bb7c2537824e94d674fc43946;p=scpubgit%2FQ-Branch.git make the DBIC required warning scoped --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 31ed6fb..855438e 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -553,7 +553,7 @@ sub _expand_expr { die "notreached"; } -our $Nest_Warning_Emitted = 0; +my $Nest_Warned = 0; sub _expand_expr_hashpair { my ($self, $k, $v, $logic) = @_; @@ -571,10 +571,17 @@ 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++; + # DBIx::Class requires a nest warning to be emitted once but the private + # method it overrode to do so no longer exists + if (ref($self) =~ /^DBIx::Class::SQLMaker/) { + unless ($Nest_Warned) { + belch( + "-nest in search conditions is deprecated, you most probably wanted:\n" + .q|{..., -and => [ \%cond0, \@cond1, \'cond2', \[ 'cond3', [ col => bind ] ], etc. ], ... }| + ); + $Nest_Warned = 1; + } + } return $self->_expand_expr($v); } if ($k eq '-bool') { diff --git a/t/01generate.t b/t/01generate.t index 008c7ca..4fa38ed 100644 --- a/t/01generate.t +++ b/t/01generate.t @@ -16,12 +16,6 @@ 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 = ( { func => 'select',