From: Justin Hunter Date: Fri, 13 Mar 2009 19:02:58 +0000 (+0000) Subject: auto-add relations if they are used in the where but not in join X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f4ca1906932c6127745d5b23524f61be24f4c2ee;p=dbsrgits%2FDBIx-Class-Historic.git auto-add relations if they are used in the where but not in join --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 99ce6ce..b5d8086 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -313,6 +313,11 @@ sub search_rs { : undef ); + foreach my $key (keys %$cond) { + next unless my ($alias) = ($key =~ /^(\w+)\.\w+$/); + push @{$new_attrs->{join}}, $alias unless grep(/${alias}/, @{$new_attrs->{join}}) or $alias eq 'me'; + } + if (defined $where) { $new_attrs->{where} = ( defined $new_attrs->{where}