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', |
35c2ee73 |
74 | { 'foreign.cdid' => 'self.cd' } |
0567538f |
75 | ); |
76 | |
77 | DBICTest::Schema::Track->add_relationship( |
78 | cd => 'DBICTest::Schema::CD', |
35c2ee73 |
79 | { 'foreign.cdid' => 'self.cd' } |
0567538f |
80 | ); |
81 | |
82 | DBICTest::Schema::TwoKeys->add_relationship( |
83 | artist => 'DBICTest::Schema::Artist', |
84 | { 'foreign.artistid' => 'self.artist' } |
85 | ); |
86 | DBICTest::Schema::TwoKeys->add_relationship( |
87 | cd => 'DBICTest::Schema::CD', |
88 | { 'foreign.cdid' => 'self.cd' } |
89 | ); |
90 | |
7411204b |
91 | DBICTest::Schema::CD_to_Producer->add_relationship( |
92 | cd => 'DBICTest::Schema::CD', |
93 | { 'foreign.cdid' => 'self.cd' } |
94 | ); |
95 | DBICTest::Schema::CD_to_Producer->add_relationship( |
96 | producer => 'DBICTest::Schema::Producer', |
97 | { 'foreign.producerid' => 'self.producer' } |
98 | ); |
99 | |
100 | # now the Helpers |
101 | DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer'); |
102 | |
0567538f |
103 | 1; |