X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship%2FBase.pm;h=b10c6870d96090ad08c6aac311fac8474c59ade6;hb=6d1bf0a9d5c6d11bd70b7d6938403530faeebc2d;hp=e4d74888800a0d3e4f0d1a3c0fd6b3e3d3f66191;hpb=701da8c4d6f0b78ffc015085aa410a6cacfcdb40;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index e4d7488..b10c687 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -51,7 +51,7 @@ command immediately before C. An arrayref containing a list of accessors in the foreign class to proxy in the main class. If, for example, you do the following: - __PACKAGE__->might_have(bar => 'Bar', undef, { proxy => qw[/ margle /] }); + __PACKAGE__->might_have(bar => 'Bar', undef, { proxy => [ qw/margle/ ] }); Then, assuming Bar has an accessor named margle, you can do: @@ -99,6 +99,22 @@ sub search_related { my $query = ((@_ > 1) ? {@_} : shift); my ($cond) = $self->result_source->resolve_condition($rel_obj->{cond}, $rel, $self); + if (ref $cond eq 'ARRAY') { + $cond = [ map { my %hash; + foreach my $key (keys %{$_}) { + unless ($key =~ m/\./) { + $hash{"me.$key"} = $_->{$key}; + } else { + $hash{$key} = $_->{$key}; + } + }; \%hash; } @$cond ]; + } else { + foreach my $key (keys %$cond) { + unless ($key =~ m/\./) { + $cond->{"me.$key"} = delete $cond->{$key}; + } + } + } $query = ($query ? { '-and' => [ $cond, $query ] } : $cond); #use Data::Dumper; warn Dumper($cond); #warn $rel_obj->{class}." $meth $cond ".join(', ', @{$attrs->{bind}||[]});