Support default aliases in many_to_many accessors. Update where test classes to use...
Michael Leuchtenburg [Thu, 10 Aug 2006 19:49:02 +0000 (19:49 +0000)]
Remove warning about pseudohashes with array ref where/cond in ResultSet::search_rs.

lib/DBIx/Class/Relationship/ManyToMany.pm
lib/DBIx/Class/ResultSet.pm
t/lib/DBICTest/Schema/Collection.pm

index ea004e3..65eab45 100644 (file)
@@ -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(@_) : {};
index fdf5867..91b7b44 100644 (file)
@@ -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' => [
index d9e4a5a..1c11dc6 100644 (file)
@@ -21,10 +21,10 @@ __PACKAGE__->has_many( collection_object => "DBICTest::Schema::CollectionObject"
                      );\r
 __PACKAGE__->many_to_many( objects => collection_object => "object" );\r
 __PACKAGE__->many_to_many( pointy_objects => collection_object => "object",\r
-                           { where => { "type" => "pointy" } } \r
+                           { where => { "object.type" => "pointy" } }\r
                          );\r
 __PACKAGE__->many_to_many( round_objects => collection_object => "object",\r
-                           { where => { "type" => "round" } } \r
+                           { where => { "object.type" => "round" } } \r
                          );\r
 \r
 1;\r