From: Matt S Trout Date: Fri, 20 Feb 2009 18:12:38 +0000 (+0000) Subject: fix test bug, also: fuck you, multi create X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8cfe052cf677d59495583c26c8dd3f2c74fbe289;p=dbsrgits%2FDBIx-Class-Historic.git fix test bug, also: fuck you, multi create --- diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 2b90433..b004d24 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -290,7 +290,10 @@ sub insert { MULTICREATE_DEBUG and warn "MC $self pre-reconstructing $relname $rel_obj\n"; my $them = { %{$rel_obj->{_relationship_data} || {} }, $rel_obj->get_inflated_columns }; - my $re = $self->find_or_create_related($relname, $them); + my $re = $self->result_source + ->related_source($relname) + ->resultset + ->find_or_create($them); %{$rel_obj} = %{$re}; $self->set_from_related($relname, $rel_obj); delete $related_stuff{$relname}; diff --git a/t/96multi_create_new.t b/t/96multi_create_new.t index 3d7c1f1..9b905eb 100644 --- a/t/96multi_create_new.t +++ b/t/96multi_create_new.t @@ -6,7 +6,7 @@ use Test::Exception; use lib qw(t/lib); use DBICTest; -plan tests => 9; +plan tests => 12; my $schema = DBICTest->init_schema(); @@ -36,7 +36,18 @@ my $schema = DBICTest->init_schema(); { my $new_artist = $schema->resultset("Artist")->new_result({ 'name' => 'Depeche Mode' }); - my $new_related_cd = $new_artist->new_related('cds', { 'title' => 'Leave in Silence', 'year' => 1982}); + my $new_related_cd = $new_artist->new_related('cds', { 'title' => 'Leave Slightly Noisily', 'year' => 1982}); + eval { + $new_related_cd->insert; + }; + is ($@, '', 'CD insertion survives by finding artist'); + ok($new_artist->in_storage, 'artist inserted'); + ok($new_related_cd->in_storage, 'new_related_cd inserted'); +} + +{ + my $new_artist = $schema->resultset("Artist")->new_result({ 'name' => 'Depeche Mode 2: Insertion Boogaloo' }); + my $new_related_cd = $new_artist->new_related('cds', { 'title' => 'Leave Loudly While Singing Off Key', 'year' => 1982}); eval { $new_related_cd->insert; };