From: Peter Rabbitson Date: Fri, 12 Jun 2009 07:00:02 +0000 (+0000) Subject: This is not update_or_create - create any non-belongs_to without asking many questions X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=439e2424aef332170873b12c186743f058ac781f;p=dbsrgits%2FDBIx-Class-Historic.git This is not update_or_create - create any non-belongs_to without asking many questions --- diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index b2eee57..a26f654 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -377,7 +377,7 @@ sub insert { my $re = $self->result_source ->related_source($relname) ->resultset - ->find_or_create($them); + ->create($them); %{$obj} = %{$re}; MULTICREATE_DEBUG and warn "MC $self new $relname $obj"; } diff --git a/t/96multi_create.t b/t/96multi_create.t index 9cd754f..856a158 100644 --- a/t/96multi_create.t +++ b/t/96multi_create.t @@ -6,7 +6,7 @@ use Test::Exception; use lib qw(t/lib); use DBICTest; -plan tests => 93; +plan tests => 92; my $schema = DBICTest->init_schema(); @@ -328,7 +328,7 @@ lives_ok ( sub { is($newartist2->name, 'Fred 3', 'Created new artist with cds via find_or_create'); }, 'Nested find_or_create'); -lives_ok ( sub { +throws_ok ( sub { my $artist2 = $schema->resultset('Artist')->create({ name => 'Fred 4', cds => [ @@ -344,9 +344,7 @@ lives_ok ( sub { }, ] }); - - is($artist2->in_storage, 1, 'artist with duplicate rels inserted okay'); -}, 'Multiple same level has_many create'); +}, qr/title are not unique/, 'Multiple same level has_many create fails with duplicate error'); lives_ok ( sub { my $artist = $schema->resultset('Artist')->first;