groditi: Guillermo Roditi <groditi@cpan.org>
+guacamole: Fred Steinberg <fred.steinberg@gmail.com>
+
Haarg: Graham Knop <haarg@haarg.org>
hobbs: Andrew Rodland <arodland@cpan.org>
return unless $column_info->{is_file_column};
+ # DO NOT CHANGE
+ # This call to id() is generally incorrect - will not DTRT on
+ # multicolumn key. However changing this may introduce
+ # backwards-comp regressions, thus leaving as is
my $id = $self->id || $self->throw_exception(
'id required for filename generation'
);
sub _create_ID {
my ($self, %vals) = @_;
- return undef unless 0 == grep { !defined } values %vals;
+ return undef if grep { !defined } values %vals;
return join '|', ref $self || $self, $self->result_source->name,
map { $_ . '=' . $vals{$_} } sort keys %vals;
}
my $copied = $rel_names_copied->{ $rel_info->{source} } ||= {};
foreach my $related ($self->search_related($rel_name)->all) {
- my $id_str = join("\0", $related->id);
- next if $copied->{$id_str};
- $copied->{$id_str} = 1;
- my $rel_copy = $related->copy($resolved);
+ $related->copy($resolved)
+ unless $copied->{$related->ID}++;
}
}
is($cover_cds->count, $artist_cds->count, 'duplicated rows count ok');
#check multi-keyed
-cmp_ok($cover_band->search_related('twokeys')->count, '>', 0, 'duplicated multiPK ok');
+is(
+ $cover_band->search_related('twokeys')->count,
+ $artist->search_related('twokeys')->count,
+ 'duplicated multiPK ok'
+);
#and check copying a few relations away
cmp_ok($cover_cds->search_related('tags')->count, '==',
$artist_cds->search_related('tags')->count , 'duplicated count ok');
+
+# check from the other side
+my $cd = $schema->resultset('CD')->find(1);
+my $dup_cd = $cd->copy ({ title => 'ha!' });
+is(
+ $dup_cd->search_related('twokeys')->count,
+ $cd->search_related('twokeys')->count,
+ 'duplicated multiPK ok'
+);
+
done_testing;
cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd'
);
+__PACKAGE__->has_many( twokeys => 'DBICTest::Schema::TwoKeys', 'cd' );
+
+
# the undef condition in this rel is *deliberate*
# tests oddball legacy syntax
__PACKAGE__->might_have(
{'foreign.artistid'=>'self.artist'},
);
-__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD', undef, { is_deferrable => 0, add_fk_index => 0 } );
+__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD', undef, { is_deferrable => 0, on_update => undef, on_delete => undef, add_fk_index => 0 } );
__PACKAGE__->has_many(
'fourkeys_to_twokeys', 'DBICTest::Schema::FourKeys_to_TwoKeys', {