Commit | Line | Data |
0567538f |
1 | package DBICTest::Schema::BasicRels; |
2 | |
3 | use base 'DBIx::Class::Core'; |
4 | |
5 | DBICTest::Schema::Artist->add_relationship( |
6 | cds => 'DBICTest::Schema::CD', |
7 | { 'foreign.artist' => 'self.artistid' }, |
54540863 |
8 | { order_by => 'year', join_type => 'LEFT', cascade_delete => 1 } |
0567538f |
9 | ); |
10 | DBICTest::Schema::Artist->add_relationship( |
11 | twokeys => 'DBICTest::Schema::TwoKeys', |
12 | { 'foreign.artist' => 'self.artistid' } |
13 | ); |
14 | DBICTest::Schema::Artist->add_relationship( |
15 | onekeys => 'DBICTest::Schema::OneKey', |
16 | { 'foreign.artist' => 'self.artistid' } |
17 | ); |
5efe4c79 |
18 | DBICTest::Schema::Artist->add_relationship( |
19 | artist_undirected_maps => 'DBICTest::Schema::ArtistUndirectedMap', |
20 | [{'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'}], |
21 | { accessor => 'multi' } |
22 | ); |
23 | DBICTest::Schema::ArtistUndirectedMap->add_relationship( |
24 | 'mapped_artists', 'DBICTest::Schema::Artist', |
25 | [{'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'}] |
26 | ); |
0567538f |
27 | DBICTest::Schema::CD->add_relationship( |
28 | artist => 'DBICTest::Schema::Artist', |
29 | { 'foreign.artistid' => 'self.artist' }, |
8452e496 |
30 | { accessor => 'filter' }, |
0567538f |
31 | ); |
32 | DBICTest::Schema::CD->add_relationship( |
33 | tracks => 'DBICTest::Schema::Track', |
54540863 |
34 | { 'foreign.cd' => 'self.cdid' }, |
35 | { join_type => 'LEFT', cascade_delete => 1 } |
0567538f |
36 | ); |
37 | DBICTest::Schema::CD->add_relationship( |
38 | tags => 'DBICTest::Schema::Tag', |
54540863 |
39 | { 'foreign.cd' => 'self.cdid' }, |
40 | { join_type => 'LEFT', cascade_delete => 1 } |
0567538f |
41 | ); |
42 | #DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes' => qw/notes/); |
43 | DBICTest::Schema::CD->add_relationship( |
44 | liner_notes => 'DBICTest::Schema::LinerNotes', |
45 | { 'foreign.liner_id' => 'self.cdid' }, |
8452e496 |
46 | { join_type => 'LEFT', accessor => 'single' } |
0567538f |
47 | ); |
7411204b |
48 | DBICTest::Schema::CD->add_relationship( |
49 | cd_to_producer => 'DBICTest::Schema::CD_to_Producer', |
50 | { 'foreign.cd' => 'self.cdid' }, |
51 | { join_type => 'LEFT', cascade_delete => 1 } |
52 | ); |
0567538f |
53 | |
54 | DBICTest::Schema::SelfRefAlias->add_relationship( |
55 | self_ref => 'DBICTest::Schema::SelfRef', |
56 | { 'foreign.id' => 'self.self_ref' }, |
57 | { accessor => 'single' } |
58 | |
59 | ); |
60 | DBICTest::Schema::SelfRefAlias->add_relationship( |
61 | alias => 'DBICTest::Schema::SelfRef', |
62 | { 'foreign.id' => 'self.alias' }, |
63 | { accessor => 'single' } |
64 | ); |
65 | |
66 | DBICTest::Schema::SelfRef->add_relationship( |
67 | aliases => 'DBICTest::Schema::SelfRefAlias', |
68 | { 'foreign.self_ref' => 'self.id' }, |
69 | { accessor => 'multi' } |
70 | ); |
71 | |
72 | DBICTest::Schema::Tag->add_relationship( |
73 | cd => 'DBICTest::Schema::CD', |
b3e8ac9b |
74 | { 'foreign.cdid' => 'self.cd' }, |
75 | { accessor => 'single' } |
0567538f |
76 | ); |
77 | |
78 | DBICTest::Schema::Track->add_relationship( |
79 | cd => 'DBICTest::Schema::CD', |
35c2ee73 |
80 | { 'foreign.cdid' => 'self.cd' } |
0567538f |
81 | ); |
82 | |
83 | DBICTest::Schema::TwoKeys->add_relationship( |
84 | artist => 'DBICTest::Schema::Artist', |
85 | { 'foreign.artistid' => 'self.artist' } |
86 | ); |
87 | DBICTest::Schema::TwoKeys->add_relationship( |
88 | cd => 'DBICTest::Schema::CD', |
89 | { 'foreign.cdid' => 'self.cd' } |
90 | ); |
91 | |
7411204b |
92 | DBICTest::Schema::CD_to_Producer->add_relationship( |
93 | cd => 'DBICTest::Schema::CD', |
94 | { 'foreign.cdid' => 'self.cd' } |
95 | ); |
96 | DBICTest::Schema::CD_to_Producer->add_relationship( |
97 | producer => 'DBICTest::Schema::Producer', |
98 | { 'foreign.producerid' => 'self.producer' } |
99 | ); |
100 | |
101 | # now the Helpers |
102 | DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer'); |
0f6ac8bb |
103 | DBICTest::Schema::CD->many_to_many( 'producers_sorted', 'cd_to_producer', 'producer', { order_by => 'producer.name' }); |
7411204b |
104 | |
0567538f |
105 | 1; |