X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FDBICTest%2FSchema%2FHelperRels.pm;h=2f99d7b1a4443725296a6a176c422b6a4d8e6d68;hb=7b6017716effef9d7467a9d8ef68068b3720a2e0;hp=4c74bc46ed77bbedbd6d8d8f412b36163d4dfbf9;hpb=0567538f9dcf59ff0dcf0fe766815b242115ce20;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/lib/DBICTest/Schema/HelperRels.pm b/t/lib/DBICTest/Schema/HelperRels.pm index 4c74bc4..2f99d7b 100644 --- a/t/lib/DBICTest/Schema/HelperRels.pm +++ b/t/lib/DBICTest/Schema/HelperRels.pm @@ -2,79 +2,34 @@ package DBICTest::Schema::BasicRels; use base 'DBIx::Class::Core'; -DBICTest::Schema::Artist->add_relationship( - cds => 'DBICTest::Schema::CD', - { 'foreign.artist' => 'self.artistid' }, - { order_by => 'year' } -); -DBICTest::Schema::Artist->add_relationship( - twokeys => 'DBICTest::Schema::TwoKeys', - { 'foreign.artist' => 'self.artistid' } -); -DBICTest::Schema::Artist->add_relationship( - onekeys => 'DBICTest::Schema::OneKey', - { 'foreign.artist' => 'self.artistid' } -); +DBICTest::Schema::Artist->has_many(cds => 'DBICTest::Schema::CD', undef, + { order_by => 'year' }); +DBICTest::Schema::Artist->has_many(twokeys => 'DBICTest::Schema::TwoKeys'); +DBICTest::Schema::Artist->has_many(onekeys => 'DBICTest::Schema::OneKey'); -DBICTest::Schema::CD->has_one('artist', 'DBICTest::Schema::Artist'); -#DBICTest::Schema::CD->add_relationship( -# artist => 'DBICTest::Schema::Artist', -# { 'foreign.artistid' => 'self.artist' }, -#); -DBICTest::Schema::CD->add_relationship( - tracks => 'DBICTest::Schema::Track', - { 'foreign.cd' => 'self.cdid' } -); -DBICTest::Schema::CD->add_relationship( - tags => 'DBICTest::Schema::Tag', - { 'foreign.cd' => 'self.cdid' } -); -#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' } -); +DBICTest::Schema::CD->belongs_to('artist', 'DBICTest::Schema::Artist'); -DBICTest::Schema::SelfRefAlias->add_relationship( - self_ref => 'DBICTest::Schema::SelfRef', - { 'foreign.id' => 'self.self_ref' }, - { accessor => 'single' } +DBICTest::Schema::CD->has_many(tracks => 'DBICTest::Schema::Track'); +DBICTest::Schema::CD->has_many(tags => 'DBICTest::Schema::Tag'); -); -DBICTest::Schema::SelfRefAlias->add_relationship( - alias => 'DBICTest::Schema::SelfRef', - { 'foreign.id' => 'self.alias' }, - { accessor => 'single' } -); +DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes', + undef, { proxy => [ qw/notes/ ] }); -DBICTest::Schema::SelfRef->add_relationship( - aliases => 'DBICTest::Schema::SelfRefAlias', - { 'foreign.self_ref' => 'self.id' }, - { accessor => 'multi' } -); +DBICTest::Schema::SelfRefAlias->belongs_to( + self_ref => 'DBICTest::Schema::SelfRef'); -DBICTest::Schema::Tag->has_one('cd', 'DBICTest::Schema::CD'); -#DBICTest::Schema::Tag->add_relationship( -# cd => 'DBICTest::Schema::CD', -# { 'foreign.cdid' => 'self.cd' } -#); +DBICTest::Schema::SelfRefAlias->belongs_to( + alias => 'DBICTest::Schema::SelfRef'); -DBICTest::Schema::Track->has_one('cd', 'DBICTest::Schema::CD'); -#DBICTest::Schema::Track->add_relationship( -# cd => 'DBICTest::Schema::CD', -# { 'foreign.cdid' => 'self.cd' } -#); +DBICTest::Schema::SelfRef->has_many( + aliases => 'DBICTest::Schema::SelfRefAlias' => 'self_ref'); -DBICTest::Schema::TwoKeys->has_one('artist', 'DBICTest::Schema::Artist'); -# DBICTest::Schema::TwoKeys->add_relationship( -# artist => 'DBICTest::Schema::Artist', -# { 'foreign.artistid' => 'self.artist' } -# ); -DBICTest::Schema::TwoKeys->has_one('cd', 'DBICTest::Schema::CD'); -#DBICTest::Schema::TwoKeys->add_relationship( -# cd => 'DBICTest::Schema::CD', -# { 'foreign.cdid' => 'self.cd' } -#); +DBICTest::Schema::Tag->belongs_to('cd', 'DBICTest::Schema::CD'); + +DBICTest::Schema::Track->belongs_to('cd', 'DBICTest::Schema::CD', 'cdid'); + +DBICTest::Schema::TwoKeys->belongs_to('artist', 'DBICTest::Schema::Artist'); + +DBICTest::Schema::TwoKeys->belongs_to('cd', 'DBICTest::Schema::CD'); 1;