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-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=43da768fcaf3e4ad27f8ad87bcd7ce3a6a596a32;p=dbsrgits%2FDBIx-Class-Historic.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 $_) {