From: Peter Rabbitson Date: Fri, 24 Dec 2010 12:57:30 +0000 (+0100) Subject: Reduce warnings introduced in 450e6dbf to one per callsite X-Git-Tag: v0.08125~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=43da768fcaf3e4ad27f8ad87bcd7ce3a6a596a32;hp=8592e2d12adc3061b28c17766b47bf802cba58cd;p=dbsrgits%2FDBIx-Class.git Reduce warnings introduced in 450e6dbf to one per callsite --- diff --git a/Changes b/Changes index 3b67176..26ff929 100644 --- a/Changes +++ b/Changes @@ -5,7 +5,8 @@ Revision history for DBIx::Class pairs of column name/info at once - $rs->search now throws when called in void context, as it makes no sense (and is nearly always a sign of a bug/misdesign) - - Deprecate legacy $rs->search( %condition ) syntax + - Deprecate legacy $rs->search( %condition ) syntax (warn once per + callsite) - NULL is now supplied unquoted to all debug-objects, in order to differentiate between a real NULL and the string 'NULL' - New search() condition operator -value used to pass complex bind diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index f060d45..7b659ef 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -305,6 +305,7 @@ always return a resultset, even in list context. =cut +my $callsites_warned; sub search_rs { my $self = shift; @@ -370,8 +371,17 @@ sub search_rs { } if @_; - carp 'search( %condition ) is deprecated, use search( \%condition ) instead' - if (@_ > 1 and ! $self->result_source->result_class->isa('DBIx::Class::CDBICompat') ); + if( @_ > 1 and ! $self->result_source->result_class->isa('DBIx::Class::CDBICompat') ) { + # determine callsite obeying Carp::Clan rules (fucking ugly but don't have better ideas) + my $callsite = do { + my $w; + local $SIG{__WARN__} = sub { $w = shift }; + carp; + $w + }; + carp 'search( %condition ) is deprecated, use search( \%condition ) instead' + unless $callsites_warned->{$callsite}++; + } for ($old_where, $call_cond) { if (defined $_) {