1 package DBICTest::Schema::BasicRels;
3 use base 'DBIx::Class::Core';
5 DBICTest::Schema::Artist->add_relationship(
6 cds => 'DBICTest::Schema::CD',
7 { 'foreign.artist' => 'self.artistid' },
8 { order_by => 'year', join_type => 'LEFT', cascade_delete => 1, cascade_copy => 1, accessor => 'multi' }
10 DBICTest::Schema::Artist->add_relationship(
11 twokeys => 'DBICTest::Schema::TwoKeys',
12 { 'foreign.artist' => 'self.artistid' },
15 DBICTest::Schema::Artist->add_relationship(
16 onekeys => 'DBICTest::Schema::OneKey',
17 { 'foreign.artist' => 'self.artistid' }
19 DBICTest::Schema::Artist->add_relationship(
20 artist_undirected_maps => 'DBICTest::Schema::ArtistUndirectedMap',
21 [{'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'}],
22 { accessor => 'multi' }
24 DBICTest::Schema::ArtistUndirectedMap->add_relationship(
25 'mapped_artists', 'DBICTest::Schema::Artist',
26 [{'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'}]
28 DBICTest::Schema::CD->add_relationship(
29 artist => 'DBICTest::Schema::Artist',
30 { 'foreign.artistid' => 'self.artist' },
31 { accessor => 'filter' },
33 DBICTest::Schema::CD->add_relationship(
34 tracks => 'DBICTest::Schema::Track',
35 { 'foreign.cd' => 'self.cdid' },
36 { join_type => 'LEFT', cascade_delete => 1 }
38 DBICTest::Schema::CD->add_relationship(
39 tags => 'DBICTest::Schema::Tag',
40 { 'foreign.cd' => 'self.cdid' },
41 { join_type => 'LEFT', cascade_delete => 1, cascade_copy => 1, accessor => 'multi' }
43 #DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes' => qw/notes/);
44 DBICTest::Schema::CD->add_relationship(
45 liner_notes => 'DBICTest::Schema::LinerNotes',
46 { 'foreign.liner_id' => 'self.cdid' },
47 { join_type => 'LEFT', accessor => 'single' }
49 DBICTest::Schema::CD->add_relationship(
50 cd_to_producer => 'DBICTest::Schema::CD_to_Producer',
51 { 'foreign.cd' => 'self.cdid' },
52 { join_type => 'LEFT', cascade_delete => 1 }
55 DBICTest::Schema::SelfRefAlias->add_relationship(
56 self_ref => 'DBICTest::Schema::SelfRef',
57 { 'foreign.id' => 'self.self_ref' },
58 { accessor => 'single' }
61 DBICTest::Schema::SelfRefAlias->add_relationship(
62 alias => 'DBICTest::Schema::SelfRef',
63 { 'foreign.id' => 'self.alias' },
64 { accessor => 'single' }
67 DBICTest::Schema::SelfRef->add_relationship(
68 aliases => 'DBICTest::Schema::SelfRefAlias',
69 { 'foreign.self_ref' => 'self.id' },
70 { accessor => 'multi' }
73 DBICTest::Schema::Tag->add_relationship(
74 cd => 'DBICTest::Schema::CD',
75 { 'foreign.cdid' => 'self.cd' },
76 { accessor => 'single' }
79 DBICTest::Schema::Track->add_relationship(
80 cd => 'DBICTest::Schema::CD',
81 { 'foreign.cdid' => 'self.cd' }
84 DBICTest::Schema::TwoKeys->add_relationship(
85 artist => 'DBICTest::Schema::Artist',
86 { 'foreign.artistid' => 'self.artist' }
88 DBICTest::Schema::TwoKeys->add_relationship(
89 cd => 'DBICTest::Schema::CD',
90 { 'foreign.cdid' => 'self.cd' }
93 DBICTest::Schema::CD_to_Producer->add_relationship(
94 cd => 'DBICTest::Schema::CD',
95 { 'foreign.cdid' => 'self.cd' }
97 DBICTest::Schema::CD_to_Producer->add_relationship(
98 producer => 'DBICTest::Schema::Producer',
99 { 'foreign.producerid' => 'self.producer' }
103 DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer');
104 DBICTest::Schema::CD->many_to_many( 'producers_sorted', 'cd_to_producer', 'producer', { order_by => 'producer.name' });