added cascade_copy relationship attribute
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / BasicRels.pm
index 0d01ff9..2a4942c 100644 (file)
@@ -5,17 +5,26 @@ use base 'DBIx::Class::Core';
 DBICTest::Schema::Artist->add_relationship(
     cds => 'DBICTest::Schema::CD',
     { 'foreign.artist' => 'self.artistid' },
-    { order_by => 'year', join_type => 'LEFT', cascade_delete => 1 }
+    { order_by => 'year', join_type => 'LEFT', cascade_delete => 1, cascade_copy => 1 }
 );
 DBICTest::Schema::Artist->add_relationship(
     twokeys => 'DBICTest::Schema::TwoKeys',
-    { 'foreign.artist' => 'self.artistid' }
+    { 'foreign.artist' => 'self.artistid' },
+    { cascade_copy => 1 }
 );
 DBICTest::Schema::Artist->add_relationship(
     onekeys => 'DBICTest::Schema::OneKey',
     { 'foreign.artist' => 'self.artistid' }
 );
-
+DBICTest::Schema::Artist->add_relationship(
+    artist_undirected_maps => 'DBICTest::Schema::ArtistUndirectedMap',
+    [{'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'}],
+    { accessor => 'multi' }
+);
+DBICTest::Schema::ArtistUndirectedMap->add_relationship(
+    'mapped_artists', 'DBICTest::Schema::Artist',
+    [{'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'}]
+);
 DBICTest::Schema::CD->add_relationship(
     artist => 'DBICTest::Schema::Artist',
     { 'foreign.artistid' => 'self.artist' },
@@ -29,7 +38,7 @@ DBICTest::Schema::CD->add_relationship(
 DBICTest::Schema::CD->add_relationship(
     tags => 'DBICTest::Schema::Tag',
     { 'foreign.cd' => 'self.cdid' },
-    { join_type => 'LEFT', cascade_delete => 1 }
+    { join_type => 'LEFT', cascade_delete => 1, cascade_copy => 1 }
 );
 #DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes' => qw/notes/);
 DBICTest::Schema::CD->add_relationship(
@@ -63,7 +72,8 @@ DBICTest::Schema::SelfRef->add_relationship(
 
 DBICTest::Schema::Tag->add_relationship(
     cd => 'DBICTest::Schema::CD',
-    { 'foreign.cdid' => 'self.cd' }
+    { 'foreign.cdid' => 'self.cd' },
+    { accessor => 'single' }
 );
 
 DBICTest::Schema::Track->add_relationship(
@@ -91,5 +101,6 @@ DBICTest::Schema::CD_to_Producer->add_relationship(
 
 # now the Helpers
 DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer');
+DBICTest::Schema::CD->many_to_many( 'producers_sorted', 'cd_to_producer', 'producer', { order_by => 'producer.name' });
 
 1;