From: Matt S Trout Date: Fri, 9 Dec 2005 04:58:16 +0000 (+0000) Subject: Moved search_like to resultset X-Git-Tag: v0.05005~119^2~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=58a4bd18e28485398f71429b129ac9e2e1073e92;p=dbsrgits%2FDBIx-Class.git Moved search_like to resultset --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index ec07702..f5574ed 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -137,6 +137,23 @@ sub cursor { $attrs->{where},$attrs); } +=item search_like + +Identical to search except defaults to 'LIKE' instead of '=' in condition + +=cut + +sub search_like { + my $class = shift; + my $attrs = { }; + if (@_ > 1 && ref $_[$#_] eq 'HASH') { + $attrs = pop(@_); + } + my $query = ref $_[0] eq "HASH" ? { %{shift()} }: {@_}; + $query->{$_} = { 'like' => $query->{$_} } for keys %$query; + return $class->search($query, { %$attrs }); +} + =item slice return a number of elements from the given resultset. diff --git a/lib/DBIx/Class/ResultSetInstance.pm b/lib/DBIx/Class/ResultSetInstance.pm index 022ca20..736ac71 100644 --- a/lib/DBIx/Class/ResultSetInstance.pm +++ b/lib/DBIx/Class/ResultSetInstance.pm @@ -4,6 +4,7 @@ use base qw/DBIx::Class/; sub search { shift->resultset_instance->search(@_); } sub search_literal { shift->resultset_instance->search_literal(@_); } +sub search_like { shift->resultset_instance->search_like(@_); } sub count { shift->resultset_instance->count(@_); } sub count_literal { shift->resultset_instance->count_literal(@_); } diff --git a/lib/DBIx/Class/Table.pm b/lib/DBIx/Class/Table.pm index e322a0c..fa8ecc0 100644 --- a/lib/DBIx/Class/Table.pm +++ b/lib/DBIx/Class/Table.pm @@ -74,23 +74,6 @@ sub construct_resultset { return $rs_class->new($class); } -=item search_like - -Identical to search except defaults to 'LIKE' instead of '=' in condition - -=cut - -sub search_like { - my $class = shift; - my $attrs = { }; - if (@_ > 1 && ref $_[$#_] eq 'HASH') { - $attrs = pop(@_); - } - my $query = ref $_[0] eq "HASH" ? { %{shift()} }: {@_}; - $query->{$_} = { 'like' => $query->{$_} } for keys %$query; - return $class->search($query, { %$attrs }); -} - sub _select_columns { return keys %{$_[0]->_columns}; }