Skip to content

Commit

Permalink
Upgrade the "too many args on customcond" warning from 1adbd3f to an …
Browse files Browse the repository at this point in the history
…exception
  • Loading branch information
ribasushi committed Jul 27, 2014
1 parent 2f76bad commit 7967dce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/DBIx/Class/ResultSource.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1864,8 +1864,8 @@ sub _resolve_relationship_condition {

($ret->{condition}, $ret->{join_free_condition}, my @extra) = $args->{condition}->($cref_args);

# FIXME sanity check
carp_unique('A custom condition coderef can return at most 2 conditions: extra return values discarded')
# sanity check
$self->throw_exception("A custom condition coderef can return at most 2 conditions, but $exception_rel_id returned extra values: @extra")
if @extra;

if (my $jfc = $ret->{join_free_condition}) {
Expand Down
5 changes: 5 additions & 0 deletions t/relationship/custom.t
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,9 @@ is_deeply
'set from related via coderef cond inflates properly',
;

throws_ok {
local $schema->source('Track')->relationship_info('cd_cref_cond')->{cond} = sub { 1,2,3 };
$schema->resultset('Track')->find({ cd_cref_cond => {} });
} qr/\QA custom condition coderef can return at most 2 conditions, but relationship 'cd_cref_cond' on source 'Track' returned extra values: 3/;

done_testing;

0 comments on commit 7967dce

Please sign in to comment.