Skip to content

Commit

Permalink
Make sure array-relconds edge case is handled properly
Browse files Browse the repository at this point in the history
Hopefully nobody in the wild is using this... hahaha who am I kidding. Anyway
being thorough before subsequent commits
  • Loading branch information
ribasushi committed Jul 3, 2015
1 parent 88e5704 commit de54e8b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/DBIx/Class/ResultSource.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2127,7 +2127,13 @@ sub _resolve_relationship_condition {

# we got something back - sanity check and infer values if we can
my @nonvalues;
if ( my $jfc = $ret->{join_free_condition} and $ret->{join_free_condition} ne UNRESOLVABLE_CONDITION ) {
if (
$ret->{join_free_condition}
and
$ret->{join_free_condition} ne UNRESOLVABLE_CONDITION
and
my $jfc = $storage->_collapse_cond( $ret->{join_free_condition} )
) {

my $jfc_eqs = $storage->_extract_fixed_condition_columns($jfc, 'consider_nulls');

Expand Down
16 changes: 16 additions & 0 deletions t/relationship/core.t
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,22 @@ is_same_sql_bind (
$undir_maps = $schema->resultset("Artist")->find(2)->artist_undirected_maps;
is($undir_maps->count, 1, 'found 1 undirected map for artist 2');

{
my $artist_to_mangle = $schema->resultset('Artist')->find(2);

$artist_to_mangle->set_from_related( artist_undirected_maps => { id1 => 42 } );

ok( ! $artist_to_mangle->is_changed, 'Unresolvable set_from_related did not alter object' );

$artist_to_mangle->set_from_related( artist_undirected_maps => {} );
ok( $artist_to_mangle->is_changed, 'Definitive set_from_related did alter object' );
is (
$artist_to_mangle->id,
undef,
'Correctly unset id on definitive outcome of OR condition',
);
}

my $mapped_rs = $undir_maps->search_related('mapped_artists');

my @art = $mapped_rs->all;
Expand Down

0 comments on commit de54e8b

Please sign in to comment.