Skip to content

Commit 7df2b5d

Browse files
committed
Yet another missed sanity check in the relcond resolver
rel/col duality is just hateful
1 parent bad0b73 commit 7df2b5d

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

lib/DBIx/Class/ResultSource.pm

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,11 +1973,26 @@ sub _resolve_relationship_condition {
19731973
$joinfree_source->columns
19741974
};
19751975

1976-
$fq_col_list->{$_} or $self->throw_exception (
1976+
exists $fq_col_list->{$_} or $self->throw_exception (
19771977
"The join-free condition returned for $exception_rel_id may only "
1978-
. 'contain keys that are fully qualified column names of the corresponding source'
1978+
. 'contain keys that are fully qualified column names of the corresponding source '
1979+
. "(it returned '$_')"
19791980
) for keys %$jfc;
19801981

1982+
(
1983+
length ref $_
1984+
and
1985+
defined blessed($_)
1986+
and
1987+
$_->isa('DBIx::Class::Row')
1988+
and
1989+
$self->throw_exception (
1990+
"The join-free condition returned for $exception_rel_id may not "
1991+
. 'contain result objects as values - perhaps instead of invoking '
1992+
. '->$something you meant to return ->get_column($something)'
1993+
)
1994+
) for values %$jfc;
1995+
19811996
}
19821997
}
19831998
elsif (ref $args->{condition} eq 'HASH') {

t/lib/DBICTest/Schema/Track.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ sub {
6767
},
6868

6969
! $args->{self_result_object} ? () : {
70-
"$args->{foreign_alias}.cdid" => $args->{self_result_object}->cd
70+
"$args->{foreign_alias}.cdid" => $args->{self_result_object}->get_column('cd')
7171
},
7272

7373
! $args->{foreign_values} ? () : {

t/relationship/custom.t

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ my $cd_single_track = $schema->resultset('CD')->create({
285285

286286
my $single_track = $cd_single_track->tracks->next;
287287

288+
is(
289+
$single_track->cd_cref_cond->title,
290+
$cd_single_track->title,
291+
'Got back the expected single-track cd title',
292+
);
293+
288294
is_deeply
289295
{ $schema->resultset('Track')->find({ cd_cref_cond => { cdid => $cd_single_track->id } })->get_columns },
290296
{ $single_track->get_columns },

0 commit comments

Comments
 (0)