new config option to DBICTest to let you set an alternative storage type, start on...
[dbsrgits/DBIx-Class.git] / t / 96multi_create.t
index 9c5522b..a6394cf 100644 (file)
@@ -51,6 +51,23 @@ my $newartist2 = $schema->resultset('Artist')->find_or_create({ name => 'Fred 3'
 
 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 :{
 
@@ -173,8 +190,17 @@ my $new_cd_hashref = {
 
 my $cd = $schema->resultset("CD")->find(1);
 
-print $cd->artist->id;
 is($cd->artist->id, 1, 'rel okay');
 
 my $new_cd = $schema->resultset("CD")->create($new_cd_hashref);
-is($new_cd->artist->id, 17, 'new id retained okay');
\ No newline at end of file
+is($new_cd->artist->id, 17, 'new id retained okay');
+
+
+# Make sure exceptions from errors in created rels propogate
+eval {
+    my $t = $schema->resultset("Track")->new({});
+    $t->cd($t->new_related('cd', { artist => undef } ) );
+    $t->{_rel_in_storage} = 0;
+    $t->insert;
+};
+like($@, qr/cd.artist may not be NULL/, "Exception propogated properly");