X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FDBICTest%2FSchema%2FBasicRels.pm;h=161e8149b356ad65a01474472cf3d64da0330cac;hb=45fa82889e637f9382eb2890b44fc58ef122de25;hp=535b6193e434510a0dc33c705e16a6f3419bf77e;hpb=0567538f9dcf59ff0dcf0fe766815b242115ce20;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/lib/DBICTest/Schema/BasicRels.pm b/t/lib/DBICTest/Schema/BasicRels.pm index 535b619..161e814 100644 --- a/t/lib/DBICTest/Schema/BasicRels.pm +++ b/t/lib/DBICTest/Schema/BasicRels.pm @@ -1,40 +1,57 @@ -package DBICTest::Schema::BasicRels; +package # hide from PAUSE + DBICTest::Schema::BasicRels; use base 'DBIx::Class::Core'; DBICTest::Schema::Artist->add_relationship( cds => 'DBICTest::Schema::CD', { 'foreign.artist' => 'self.artistid' }, - { order_by => 'year' } + { order_by => 'year', join_type => 'LEFT', cascade_delete => 1, cascade_copy => 1, accessor => 'multi' } ); 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' }, + { accessor => 'filter' }, ); DBICTest::Schema::CD->add_relationship( tracks => 'DBICTest::Schema::Track', - { 'foreign.cd' => 'self.cdid' } + { 'foreign.cd' => 'self.cdid' }, + { join_type => 'LEFT', cascade_delete => 1 } ); DBICTest::Schema::CD->add_relationship( tags => 'DBICTest::Schema::Tag', - { 'foreign.cd' => 'self.cdid' } + { 'foreign.cd' => 'self.cdid' }, + { join_type => 'LEFT', cascade_delete => 1, cascade_copy => 1, accessor => 'multi', order_by => 'tag' } ); #DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes' => qw/notes/); DBICTest::Schema::CD->add_relationship( liner_notes => 'DBICTest::Schema::LinerNotes', { 'foreign.liner_id' => 'self.cdid' }, - { join_type => 'LEFT' } + { join_type => 'LEFT', accessor => 'single' } +); +DBICTest::Schema::CD->add_relationship( + cd_to_producer => 'DBICTest::Schema::CD_to_Producer', + { 'foreign.cd' => 'self.cdid' }, + { join_type => 'LEFT', cascade_delete => 1 } ); - DBICTest::Schema::SelfRefAlias->add_relationship( self_ref => 'DBICTest::Schema::SelfRef', @@ -56,7 +73,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( @@ -73,4 +91,17 @@ DBICTest::Schema::TwoKeys->add_relationship( { 'foreign.cdid' => 'self.cd' } ); +DBICTest::Schema::CD_to_Producer->add_relationship( + cd => 'DBICTest::Schema::CD', + { 'foreign.cdid' => 'self.cd' } +); +DBICTest::Schema::CD_to_Producer->add_relationship( + producer => 'DBICTest::Schema::Producer', + { 'foreign.producerid' => 'self.producer' } +); + +# 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;