From: Matt S Trout Date: Wed, 19 Apr 2006 20:18:18 +0000 (+0000) Subject: Fix to copy X-Git-Tag: v0.06002~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=83419ec6ac275cc9f105de53c934121ec6504a22;p=dbsrgits%2FDBIx-Class.git Fix to copy --- diff --git a/Changes b/Changes index f7e9380..c736374 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for DBIx::Class 0.06002 + - fix to copy() with non-composed resultsource - fix to ->search without args to clone rs but maintain cache - grab $self->dbh once per function in Storage::DBI - nuke ResultSource caching of ->resultset for consistency reasons diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 16745b5..9a46fe5 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -255,6 +255,7 @@ sub copy { if $self->result_source->column_info($col)->{is_auto_increment}; } my $new = bless { _column_data => $col_data }, ref $self; + $new->result_source($self->result_source); $new->set_columns($changes); $new->insert; foreach my $rel ($self->result_source->relationships) { diff --git a/t/run/22cascade_copy.tl b/t/run/22cascade_copy.tl index 8c682e5..82642f2 100644 --- a/t/run/22cascade_copy.tl +++ b/t/run/22cascade_copy.tl @@ -7,7 +7,16 @@ my $schema = shift; plan tests => 4; my $artist = $schema->resultset('Artist')->find(1); my $artist_cds = $artist->search_related('cds'); -my $cover_band = $artist->copy; + +my $cover_band; + +{ + no warnings 'redefine'; + local *DBICTest::Artist::result_source_instance = \&DBICTest::Schema::Artist::result_source_instance; + + $cover_band = $artist->copy; +} + my $cover_cds = $cover_band->search_related('cds'); cmp_ok($cover_band->id, '!=', $artist->id, 'ok got new column id...'); is($cover_cds->count, $artist_cds->count, 'duplicated rows count ok');