Revision history for DBIx::Class
-
+ - Row::insert will now not fall over if passed duplicate related objects
- When adding relationships, it will throw an exception if you get the
foreign and self parts the wrong way round in the condition
- ResultSetColumn::func() now returns all results if called in list
my $reverse = $source->reverse_relationship_info($relname);
foreach my $obj (@cands) {
$obj->set_from_related($_, $self) for keys %$reverse;
- $obj->insert() if(!$obj->in_storage);
+ $obj->insert() unless ($obj->in_storage || $obj->result_source->resultset->search({$obj->get_columns})->count);
}
}
}
is($newartist2->name, 'Fred 3', 'Created new artist with cds via find_or_create');
+my $artist2 = $schema->resultset('Artist')->create({ artistid => 1000,
+ name => 'Fred 3',
+ cds => [
+ { artist => 1000,
+ title => 'Music to code by',
+ year => 2007,
+ },
+ ],
+ cds_unordered => [
+ { artist => 1000,
+ title => 'Music to code by',
+ year => 2007,
+ },
+ ]
+ });
+
+is($artist2->in_storage, 1, 'artist with duplicate rels inserted okay');
CREATE_RELATED1 :{
cds => 'DBICTest::Schema::CD', undef,
{ order_by => 'year' },
);
+__PACKAGE__->has_many(
+ cds_unordered => 'DBICTest::Schema::CD'
+);
__PACKAGE__->has_many( twokeys => 'DBICTest::Schema::TwoKeys' );
__PACKAGE__->has_many( onekeys => 'DBICTest::Schema::OneKey' );