From: Peter Rabbitson Date: Mon, 15 Sep 2014 08:40:39 +0000 (+0200) Subject: Yet another missed sanity check in the relcond resolver X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7df2b5df3d6c48b35c73a9e840d8e8ef395b11f6;p=dbsrgits%2FDBIx-Class-Historic.git Yet another missed sanity check in the relcond resolver rel/col duality is just hateful --- diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 57d833e..9e8641a 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -1973,11 +1973,26 @@ sub _resolve_relationship_condition { $joinfree_source->columns }; - $fq_col_list->{$_} or $self->throw_exception ( + exists $fq_col_list->{$_} or $self->throw_exception ( "The join-free condition returned for $exception_rel_id may only " - . 'contain keys that are fully qualified column names of the corresponding source' + . 'contain keys that are fully qualified column names of the corresponding source ' + . "(it returned '$_')" ) for keys %$jfc; + ( + length ref $_ + and + defined blessed($_) + and + $_->isa('DBIx::Class::Row') + and + $self->throw_exception ( + "The join-free condition returned for $exception_rel_id may not " + . 'contain result objects as values - perhaps instead of invoking ' + . '->$something you meant to return ->get_column($something)' + ) + ) for values %$jfc; + } } elsif (ref $args->{condition} eq 'HASH') { diff --git a/t/lib/DBICTest/Schema/Track.pm b/t/lib/DBICTest/Schema/Track.pm index 5b0811e..c43591a 100644 --- a/t/lib/DBICTest/Schema/Track.pm +++ b/t/lib/DBICTest/Schema/Track.pm @@ -67,7 +67,7 @@ sub { }, ! $args->{self_result_object} ? () : { - "$args->{foreign_alias}.cdid" => $args->{self_result_object}->cd + "$args->{foreign_alias}.cdid" => $args->{self_result_object}->get_column('cd') }, ! $args->{foreign_values} ? () : { diff --git a/t/relationship/custom.t b/t/relationship/custom.t index 5bc52d4..fb48597 100644 --- a/t/relationship/custom.t +++ b/t/relationship/custom.t @@ -285,6 +285,12 @@ my $cd_single_track = $schema->resultset('CD')->create({ my $single_track = $cd_single_track->tracks->next; +is( + $single_track->cd_cref_cond->title, + $cd_single_track->title, + 'Got back the expected single-track cd title', +); + is_deeply { $schema->resultset('Track')->find({ cd_cref_cond => { cdid => $cd_single_track->id } })->get_columns }, { $single_track->get_columns },