Fix to search_realted on relationships without attrs from ningu
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Relationship.pm
index 3fef7a3..04bb4b3 100644 (file)
@@ -43,7 +43,7 @@ sub _cond_value {
     unless ($value =~ s/^self\.//) {
       die "Unable to convert relationship to WHERE clause: invalid value ${value}";
     }
-    unless ($self->can($value)) {
+    unless ($self->_columns->{$value}) {
       die "Unable to convert relationship to WHERE clause: no such accessor ${value}";
     }
     push(@{$attrs->{bind}}, $self->get_column($value));
@@ -70,7 +70,7 @@ sub search_related {
   }
   my $rel_obj = $self->_relationships->{$rel};
   die "No such relationship ${rel}" unless $rel;
-  $attrs = { %{$rel_obj->{attrs}}, %{$attrs || {}} };
+  $attrs = { %{$rel_obj->{attrs} || {}}, %{$attrs || {}} };
   my $s_cond;
   if (@_) {
     die "Invalid query: @_" if (@_ > 1 && (@_ % 2 == 1));
@@ -80,7 +80,8 @@ sub search_related {
   $attrs->{_action} = 'convert';
   my ($cond) = $self->_cond_resolve($rel_obj->{cond}, $attrs);
   $cond = "${s_cond} AND ${cond}" if $s_cond;
-  return $rel_obj->{class}->retrieve_from_sql($cond, @{$attrs->{bind} || {}});
+  return $rel_obj->{class}->retrieve_from_sql($cond, @{$attrs->{bind} || []},
+                                                $attrs);
 }
 
 sub create_related {