X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FDBICTest%2FSchema%2FHelperRels.pm;h=59cd0a3454dddf5c6ceed2a6956c3d69d6367b37;hb=5a5bec6c01bda57e0f09e77b4e36ce84edeb5fa2;hp=de4594316f9958fad380b66a5f36b5f3f8bde2fe;hpb=89bfba91c9347d7ef481dd3f33365fdd3c003c62;p=dbsrgits%2FDBIx-Class.git diff --git a/t/lib/DBICTest/Schema/HelperRels.pm b/t/lib/DBICTest/Schema/HelperRels.pm index de45943..59cd0a3 100644 --- a/t/lib/DBICTest/Schema/HelperRels.pm +++ b/t/lib/DBICTest/Schema/HelperRels.pm @@ -1,4 +1,4 @@ -package DBICTest::Schema::BasicRels; +package DBICTest::Schema::HelperRels; use base 'DBIx::Class::Core'; @@ -10,14 +10,15 @@ DBICTest::Schema::Artist->has_many(onekeys => 'DBICTest::Schema::OneKey'); DBICTest::Schema::CD->belongs_to('artist', 'DBICTest::Schema::Artist'); DBICTest::Schema::CD->has_many(tracks => 'DBICTest::Schema::Track'); -DBICTest::Schema::CD->has_many(tags => 'DBICTest::Schema::Tag'); +DBICTest::Schema::CD->has_many(tags => 'DBICTest::Schema::Tag', undef, + { order_by => 'tag' }); +DBICTest::Schema::CD->has_many(cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd'); DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes', undef, { proxy => [ qw/notes/ ] }); DBICTest::Schema::SelfRefAlias->belongs_to( self_ref => 'DBICTest::Schema::SelfRef'); - DBICTest::Schema::SelfRefAlias->belongs_to( alias => 'DBICTest::Schema::SelfRef'); @@ -26,12 +27,35 @@ DBICTest::Schema::SelfRef->has_many( DBICTest::Schema::Tag->belongs_to('cd', 'DBICTest::Schema::CD'); -DBICTest::Schema::Track->belongs_to('cd', 'DBICTest::Schema::CD', 'cdid'); - +DBICTest::Schema::Track->belongs_to('cd', 'DBICTest::Schema::CD'); DBICTest::Schema::Track->belongs_to('disc', 'DBICTest::Schema::CD', 'cd'); DBICTest::Schema::TwoKeys->belongs_to('artist', 'DBICTest::Schema::Artist'); - DBICTest::Schema::TwoKeys->belongs_to('cd', 'DBICTest::Schema::CD'); +DBICTest::Schema::CD_to_Producer->belongs_to( + 'cd', 'DBICTest::Schema::CD', + { 'foreign.cdid' => 'self.cd' } +); +DBICTest::Schema::CD_to_Producer->belongs_to( + 'producer', 'DBICTest::Schema::Producer', + { 'foreign.producerid' => 'self.producer' } +); +DBICTest::Schema::Artist->has_many( + 'artist_undirected_maps', 'DBICTest::Schema::ArtistUndirectedMap', + [{'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'}], + { cascade_copy => 0 } # this would *so* not make sense +); +DBICTest::Schema::ArtistUndirectedMap->belongs_to( + 'artist1', 'DBICTest::Schema::Artist', 'id1'); +DBICTest::Schema::ArtistUndirectedMap->belongs_to( + 'artist2', 'DBICTest::Schema::Artist', 'id2'); +DBICTest::Schema::ArtistUndirectedMap->has_many( + 'mapped_artists', 'DBICTest::Schema::Artist', + [{'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'}]); + +# 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;