X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSource.pm;fp=lib%2FDBIx%2FClass%2FResultSource.pm;h=00d257f8051d4314648f35c48971b8d390e586c0;hb=f8193780f1e03bc6f1316204a03bf604faf9267b;hp=e1ebbf723ab684e9aa02f11d37b090067f8c91fb;hpb=32250d01415849731328c292c4f77b25a88444e6;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index e1ebbf7..00d257f 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -1697,7 +1697,7 @@ sub _resolve_condition { self_rowobj => $obj_rel ? $for : undef }); - my $cond_cols; + my @nonvalue_cols; if ($joinfree_cond) { # FIXME sanity check until things stabilize, remove at some point @@ -1705,51 +1705,34 @@ sub _resolve_condition { "A join-free condition returned for relationship '$rel_name' without a row-object to chain from" ) unless $obj_rel; + my $foreign_src_col_list = { map { ( "$relalias.$_" => 1 ) } $self->related_source($rel_name)->columns }; # FIXME another sanity check if ( ref $joinfree_cond ne 'HASH' or - first { $_ !~ /^\Q$relalias.\E.+/ } keys %$joinfree_cond + grep { ! $foreign_src_col_list } keys %$joinfree_cond ) { $self->throw_exception ( "The join-free condition returned for relationship '$rel_name' must be a hash " - .'reference with all keys being valid columns on the related result source' + .'reference with all keys being fully qualified column names of the foreign source' ); } - # normalize - for (values %$joinfree_cond) { - $_ = $_->{'='} if ( - ref $_ eq 'HASH' - and - keys %$_ == 1 - and - exists $_->{'='} - ); - } - - # see which parts of the joinfree cond are conditionals - my $relcol_list = { map { $_ => 1 } $self->related_source($rel_name)->columns }; - - for my $c (keys %$joinfree_cond) { - my ($colname) = $c =~ /^ (?: \Q$relalias.\E )? (.+)/x; - - unless ($relcol_list->{$colname}) { - push @$cond_cols, $colname; - next; - } - - if ( - ref $joinfree_cond->{$c} - and - ! is_literal_value( $joinfree_cond->{$c} ) - ) { - push @$cond_cols, $colname; - next; - } - } - - return wantarray ? ($joinfree_cond, 0, $cond_cols) : $joinfree_cond; + # see which parts of the joinfree cond are *NOT* foreign-source-column equalities + my $joinfree_cond_equality_columns = { map + {( $_ => 1 )} + @{ $self->schema->storage->_extract_fixed_condition_columns($joinfree_cond) } + }; + @nonvalue_cols = map + { $_ =~ /^\Q$relalias.\E(.+)/ } + grep + { ! $joinfree_cond_equality_columns->{$_} } + keys %$joinfree_cond; + + return wantarray + ? ($joinfree_cond, 0, (@nonvalue_cols ? \@nonvalue_cols : undef)) + : $joinfree_cond + ; } else { return wantarray ? ($crosstable_cond, 1) : $crosstable_cond;