From: Michael Leuchtenburg Date: Thu, 10 Aug 2006 19:49:02 +0000 (+0000) Subject: Support default aliases in many_to_many accessors. Update where test classes to use... X-Git-Tag: v0.07002~42 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7141bdfcd7f155c22d3e2044bf7f69663b67c801;p=dbsrgits%2FDBIx-Class.git Support default aliases in many_to_many accessors. Update where test classes to use this. Remove warning about pseudohashes with array ref where/cond in ResultSet::search_rs. --- diff --git a/lib/DBIx/Class/Relationship/ManyToMany.pm b/lib/DBIx/Class/Relationship/ManyToMany.pm index ea004e3..65eab45 100644 --- a/lib/DBIx/Class/Relationship/ManyToMany.pm +++ b/lib/DBIx/Class/Relationship/ManyToMany.pm @@ -14,6 +14,8 @@ sub many_to_many { my $remove_meth = "remove_from_${meth}"; my $set_meth = "set_${meth}"; + $rel_attrs->{alias} ||= $f_rel; + *{"${class}::${meth}"} = sub { my $self = shift; my $attrs = @_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {}; diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index fdf5867..91b7b44 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -194,7 +194,7 @@ sub search_rs { : undef ); - if (defined $where and %$where) { + if (defined $where) { $new_attrs->{where} = ( defined $new_attrs->{where} ? { '-and' => [ @@ -205,7 +205,7 @@ sub search_rs { } : $where); } - if (defined $cond and %$cond) { + if (defined $cond) { $new_attrs->{where} = ( defined $new_attrs->{where} ? { '-and' => [ diff --git a/t/lib/DBICTest/Schema/Collection.pm b/t/lib/DBICTest/Schema/Collection.pm index d9e4a5a..1c11dc6 100644 --- a/t/lib/DBICTest/Schema/Collection.pm +++ b/t/lib/DBICTest/Schema/Collection.pm @@ -21,10 +21,10 @@ __PACKAGE__->has_many( collection_object => "DBICTest::Schema::CollectionObject" ); __PACKAGE__->many_to_many( objects => collection_object => "object" ); __PACKAGE__->many_to_many( pointy_objects => collection_object => "object", - { where => { "type" => "pointy" } } + { where => { "object.type" => "pointy" } } ); __PACKAGE__->many_to_many( round_objects => collection_object => "object", - { where => { "type" => "round" } } + { where => { "object.type" => "round" } } ); 1;