1 package # hide from PAUSE
2 DBICTest::Schema::BasicRels;
4 use base 'DBIx::Class::Core';
6 DBICTest::Schema::Artist->add_relationship(
7 cds => 'DBICTest::Schema::CD',
8 { 'foreign.artist' => 'self.artistid' },
9 { order_by => 'year', join_type => 'LEFT', cascade_delete => 1, cascade_copy => 1, accessor => 'multi' }
11 DBICTest::Schema::Artist->add_relationship(
12 twokeys => 'DBICTest::Schema::TwoKeys',
13 { 'foreign.artist' => 'self.artistid' },
16 DBICTest::Schema::Artist->add_relationship(
17 onekeys => 'DBICTest::Schema::OneKey',
18 { 'foreign.artist' => 'self.artistid' }
20 DBICTest::Schema::Artist->add_relationship(
21 artist_undirected_maps => 'DBICTest::Schema::ArtistUndirectedMap',
22 [{'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'}],
23 { accessor => 'multi' }
25 DBICTest::Schema::ArtistUndirectedMap->add_relationship(
26 'mapped_artists', 'DBICTest::Schema::Artist',
27 [{'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'}]
29 DBICTest::Schema::CD->add_relationship(
30 artist => 'DBICTest::Schema::Artist',
31 { 'foreign.artistid' => 'self.artist' },
32 { accessor => 'filter' },
34 DBICTest::Schema::CD->add_relationship(
35 tracks => 'DBICTest::Schema::Track',
36 { 'foreign.cd' => 'self.cdid' },
37 { join_type => 'LEFT', cascade_delete => 1 }
39 DBICTest::Schema::CD->add_relationship(
40 tags => 'DBICTest::Schema::Tag',
41 { 'foreign.cd' => 'self.cdid' },
42 { join_type => 'LEFT', cascade_delete => 1, cascade_copy => 1, accessor => 'multi', order_by => 'tag' }
44 #DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes' => qw/notes/);
45 DBICTest::Schema::CD->add_relationship(
46 liner_notes => 'DBICTest::Schema::LinerNotes',
47 { 'foreign.liner_id' => 'self.cdid' },
48 { join_type => 'LEFT', accessor => 'single' }
50 DBICTest::Schema::CD->add_relationship(
51 cd_to_producer => 'DBICTest::Schema::CD_to_Producer',
52 { 'foreign.cd' => 'self.cdid' },
53 { join_type => 'LEFT', cascade_delete => 1 }
56 DBICTest::Schema::SelfRefAlias->add_relationship(
57 self_ref => 'DBICTest::Schema::SelfRef',
58 { 'foreign.id' => 'self.self_ref' },
59 { accessor => 'single' }
62 DBICTest::Schema::SelfRefAlias->add_relationship(
63 alias => 'DBICTest::Schema::SelfRef',
64 { 'foreign.id' => 'self.alias' },
65 { accessor => 'single' }
68 DBICTest::Schema::SelfRef->add_relationship(
69 aliases => 'DBICTest::Schema::SelfRefAlias',
70 { 'foreign.self_ref' => 'self.id' },
71 { accessor => 'multi' }
74 DBICTest::Schema::Tag->add_relationship(
75 cd => 'DBICTest::Schema::CD',
76 { 'foreign.cdid' => 'self.cd' },
77 { accessor => 'single' }
80 DBICTest::Schema::Track->add_relationship(
81 cd => 'DBICTest::Schema::CD',
82 { 'foreign.cdid' => 'self.cd' }
85 DBICTest::Schema::TwoKeys->add_relationship(
86 artist => 'DBICTest::Schema::Artist',
87 { 'foreign.artistid' => 'self.artist' }
89 DBICTest::Schema::TwoKeys->add_relationship(
90 cd => 'DBICTest::Schema::CD',
91 { 'foreign.cdid' => 'self.cd' }
94 DBICTest::Schema::CD_to_Producer->add_relationship(
95 cd => 'DBICTest::Schema::CD',
96 { 'foreign.cdid' => 'self.cd' }
98 DBICTest::Schema::CD_to_Producer->add_relationship(
99 producer => 'DBICTest::Schema::Producer',
100 { 'foreign.producerid' => 'self.producer' }
104 DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer');
105 DBICTest::Schema::CD->many_to_many( 'producers_sorted', 'cd_to_producer', 'producer', { order_by => 'producer.name' });