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 | ); |
18 | |
19 | DBICTest::Schema::CD->add_relationship( |
20 | artist => 'DBICTest::Schema::Artist', |
21 | { 'foreign.artistid' => 'self.artist' }, |
22 | ); |
23 | DBICTest::Schema::CD->add_relationship( |
24 | tracks => 'DBICTest::Schema::Track', |
54540863 |
25 | { 'foreign.cd' => 'self.cdid' }, |
26 | { join_type => 'LEFT', cascade_delete => 1 } |
0567538f |
27 | ); |
28 | DBICTest::Schema::CD->add_relationship( |
29 | tags => 'DBICTest::Schema::Tag', |
54540863 |
30 | { 'foreign.cd' => 'self.cdid' }, |
31 | { join_type => 'LEFT', cascade_delete => 1 } |
0567538f |
32 | ); |
33 | #DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes' => qw/notes/); |
34 | DBICTest::Schema::CD->add_relationship( |
35 | liner_notes => 'DBICTest::Schema::LinerNotes', |
36 | { 'foreign.liner_id' => 'self.cdid' }, |
37 | { join_type => 'LEFT' } |
38 | ); |
7411204b |
39 | DBICTest::Schema::CD->add_relationship( |
40 | cd_to_producer => 'DBICTest::Schema::CD_to_Producer', |
41 | { 'foreign.cd' => 'self.cdid' }, |
42 | { join_type => 'LEFT', cascade_delete => 1 } |
43 | ); |
0567538f |
44 | |
45 | DBICTest::Schema::SelfRefAlias->add_relationship( |
46 | self_ref => 'DBICTest::Schema::SelfRef', |
47 | { 'foreign.id' => 'self.self_ref' }, |
48 | { accessor => 'single' } |
49 | |
50 | ); |
51 | DBICTest::Schema::SelfRefAlias->add_relationship( |
52 | alias => 'DBICTest::Schema::SelfRef', |
53 | { 'foreign.id' => 'self.alias' }, |
54 | { accessor => 'single' } |
55 | ); |
56 | |
57 | DBICTest::Schema::SelfRef->add_relationship( |
58 | aliases => 'DBICTest::Schema::SelfRefAlias', |
59 | { 'foreign.self_ref' => 'self.id' }, |
60 | { accessor => 'multi' } |
61 | ); |
62 | |
63 | DBICTest::Schema::Tag->add_relationship( |
64 | cd => 'DBICTest::Schema::CD', |
65 | { 'foreign.cdid' => 'self.cd' } |
66 | ); |
67 | |
68 | DBICTest::Schema::Track->add_relationship( |
69 | cd => 'DBICTest::Schema::CD', |
70 | { 'foreign.cdid' => 'self.cd' } |
71 | ); |
72 | |
73 | DBICTest::Schema::TwoKeys->add_relationship( |
74 | artist => 'DBICTest::Schema::Artist', |
75 | { 'foreign.artistid' => 'self.artist' } |
76 | ); |
77 | DBICTest::Schema::TwoKeys->add_relationship( |
78 | cd => 'DBICTest::Schema::CD', |
79 | { 'foreign.cdid' => 'self.cd' } |
80 | ); |
81 | |
7411204b |
82 | DBICTest::Schema::CD_to_Producer->add_relationship( |
83 | cd => 'DBICTest::Schema::CD', |
84 | { 'foreign.cdid' => 'self.cd' } |
85 | ); |
86 | DBICTest::Schema::CD_to_Producer->add_relationship( |
87 | producer => 'DBICTest::Schema::Producer', |
88 | { 'foreign.producerid' => 'self.producer' } |
89 | ); |
90 | |
91 | # now the Helpers |
92 | DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer'); |
93 | |
0567538f |
94 | 1; |