Skip Menu |

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 38730
Status: resolved
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: felix.ostmann [...] thewar.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.08010
  • 0.08099_04
Fixed in: (no value)



Subject: new_related throw an error at insert when both result are new
when you make a new_result and then call new_related and insert them in the right order, the second result throw an error, becouse of unknown fk_id (cd.artist may not be NULL). but when you say at new_related additional: fk => $first_obj (artist => $new_artist), it works! (see into the test for a working and nonworking example.)
Subject: new_related-bug.patch
--- DBIx-Class-0.08099_04/t/66relationship.t 2008-08-26 13:42:51.000000000 +0200 +++ DBIx-Class-0.08099_04/t/66relationship.t.orig 2008-08-26 13:33:46.000000000 +0200 @@ -7,7 +7,7 @@ my $schema = DBICTest->init_schema(); -plan tests => 64; +plan tests => 63; # has_a test my $cd = $schema->resultset("CD")->find(4); @@ -250,13 +250,3 @@ cmp_ok($artist->cds->count, '==', 0, "Correct new #cds for artist"); cmp_ok($nartist->cds->count, '==', 2, "Correct new #cds for artist"); -my $new_artist = $schema->resultset("Artist")->new_result({ 'name' => 'Depeche Mode' }); -# why must i tell him: make a new related from me and me is me? that works! -# my $new_related_cd = $new_artist->new_related('cds', { 'title' => 'Leave in Silence', 'year' => 1982, 'artist' => $new_artist }); -my $new_related_cd = $new_artist->new_related('cds', { 'title' => 'Leave in Silence', 'year' => 1982}); -eval { - $new_artist->insert; - $new_related_cd->insert; -}; -$@ && diag($@); -ok($new_related_cd->in_storage, 'new_related_cd insert ok');
From: felix.ostmann [...] thewar.de
new patch with the right order diff new old
--- DBIx-Class-0.08099_04/t/66relationship.t.orig 2008-08-26 13:33:46.000000000 +0200 +++ DBIx-Class-0.08099_04/t/66relationship.t 2008-08-26 13:42:51.000000000 +0200 @@ -7,7 +7,7 @@ my $schema = DBICTest->init_schema(); -plan tests => 63; +plan tests => 64; # has_a test my $cd = $schema->resultset("CD")->find(4); @@ -250,3 +250,13 @@ cmp_ok($artist->cds->count, '==', 0, "Correct new #cds for artist"); cmp_ok($nartist->cds->count, '==', 2, "Correct new #cds for artist"); +my $new_artist = $schema->resultset("Artist")->new_result({ 'name' => 'Depeche Mode' }); +# why must i tell him: make a new related from me and me is me? that works! +# my $new_related_cd = $new_artist->new_related('cds', { 'title' => 'Leave in Silence', 'year' => 1982, 'artist' => $new_artist }); +my $new_related_cd = $new_artist->new_related('cds', { 'title' => 'Leave in Silence', 'year' => 1982}); +eval { + $new_artist->insert; + $new_related_cd->insert; +}; +$@ && diag($@); +ok($new_related_cd->in_storage, 'new_related_cd insert ok');
Fixed in trunk after the multicreate overhaul.