Skip to content

Commit

Permalink
Yet another missed sanity check in the relcond resolver
Browse files Browse the repository at this point in the history
rel/col duality is just hateful
  • Loading branch information
ribasushi committed Sep 15, 2014
1 parent bad0b73 commit 7df2b5d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
19 changes: 17 additions & 2 deletions lib/DBIx/Class/ResultSource.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
2 changes: 1 addition & 1 deletion t/lib/DBICTest/Schema/Track.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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} ? () : {
Expand Down
6 changes: 6 additions & 0 deletions t/relationship/custom.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down

0 comments on commit 7df2b5d

Please sign in to comment.