Revision history for DBIx::Class
+ - Fixed join merging bug (test from Zbi)
- When adding relationships, it will throw an exception if you get the
foreign and self parts the wrong way round in the condition
- ResultSetColumn::func() now returns all results if called in list
$position++;
}
my ($b_key) = ( ref $b_element eq 'HASH' ) ? keys %{$b_element} : ($b_element);
+
if ($best_candidate->{score} == 0 || exists $seen_keys->{$b_key}) {
push( @{$a}, $b_element );
} else {
- $seen_keys->{$b_key} = 1; # don't merge the same key twice
my $a_best = $a->[$best_candidate->{position}];
# merge a_best and b_element together and replace original with merged
if (ref $a_best ne 'HASH') {
$a->[$best_candidate->{position}] = { $key => $self->_merge_attr($a_best->{$key}, $b_element->{$key}) };
}
}
+ $seen_keys->{$b_key} = 1; # don't merge the same key twice
}
return $a;
use DBICTest;
my $schema = DBICTest->init_schema();
-plan tests => 20;
+plan tests => 22;
{
my $rs = $schema->resultset( 'CD' )->search(
ok(!$@, "pathological prefetch ok");
+my $rs = $schema->resultset("Artist")->search({}, { join => 'twokeys' });
+my $second_search_rs = $rs->search({ 'cds_2.cdid' => '2' }, { join =>
+['cds', 'cds'] });
+is(scalar(@{$second_search_rs->{attrs}->{join}}), 3, 'both joins kept');
+ok($second_search_rs->next, 'query on double joined rel runs okay');
+
1;
use DBICTest;
use Test::More;
-plan tests => 14;
+plan tests => 15;
my $schema = DBICTest->init_schema();
my $rs = $schema->resultset( 'CD' );
}
{
+ my $a = [ 'twokeys' ];
+ my $b = [ 'cds', 'cds' ];
+ my $expected = [ 'twokeys', 'cds', 'cds' ];
+ my $result = $rs->_merge_attr($a, $b);
+ is_deeply( $result, $expected );
+}
+
+{
my $a = [ 'artist', 'cd', { 'artist' => 'manager' } ];
my $b = 'artist';
my $expected = [ 'artist', 'cd', { 'artist' => 'manager' } ];