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' }, |
64acc2bc |
8 | { order_by => 'year', join_type => 'LEFT', cascade_delete => 1, cascade_copy => 1, accessor => 'multi' } |
0567538f |
9 | ); |
10 | DBICTest::Schema::Artist->add_relationship( |
11 | twokeys => 'DBICTest::Schema::TwoKeys', |
333cce60 |
12 | { 'foreign.artist' => 'self.artistid' }, |
13 | { cascade_copy => 1 } |
0567538f |
14 | ); |
15 | DBICTest::Schema::Artist->add_relationship( |
16 | onekeys => 'DBICTest::Schema::OneKey', |
17 | { 'foreign.artist' => 'self.artistid' } |
18 | ); |
5efe4c79 |
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' } |
23 | ); |
24 | DBICTest::Schema::ArtistUndirectedMap->add_relationship( |
25 | 'mapped_artists', 'DBICTest::Schema::Artist', |
26 | [{'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'}] |
27 | ); |
0567538f |
28 | DBICTest::Schema::CD->add_relationship( |
29 | artist => 'DBICTest::Schema::Artist', |
30 | { 'foreign.artistid' => 'self.artist' }, |
8452e496 |
31 | { accessor => 'filter' }, |
0567538f |
32 | ); |
33 | DBICTest::Schema::CD->add_relationship( |
34 | tracks => 'DBICTest::Schema::Track', |
54540863 |
35 | { 'foreign.cd' => 'self.cdid' }, |
36 | { join_type => 'LEFT', cascade_delete => 1 } |
0567538f |
37 | ); |
38 | DBICTest::Schema::CD->add_relationship( |
39 | tags => 'DBICTest::Schema::Tag', |
54540863 |
40 | { 'foreign.cd' => 'self.cdid' }, |
f9cc31dd |
41 | { join_type => 'LEFT', cascade_delete => 1, cascade_copy => 1, accessor => 'multi' } |
0567538f |
42 | ); |
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' }, |
8452e496 |
47 | { join_type => 'LEFT', accessor => 'single' } |
0567538f |
48 | ); |
7411204b |
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 } |
53 | ); |
0567538f |
54 | |
55 | DBICTest::Schema::SelfRefAlias->add_relationship( |
56 | self_ref => 'DBICTest::Schema::SelfRef', |
57 | { 'foreign.id' => 'self.self_ref' }, |
58 | { accessor => 'single' } |
59 | |
60 | ); |
61 | DBICTest::Schema::SelfRefAlias->add_relationship( |
62 | alias => 'DBICTest::Schema::SelfRef', |
63 | { 'foreign.id' => 'self.alias' }, |
64 | { accessor => 'single' } |
65 | ); |
66 | |
67 | DBICTest::Schema::SelfRef->add_relationship( |
68 | aliases => 'DBICTest::Schema::SelfRefAlias', |
69 | { 'foreign.self_ref' => 'self.id' }, |
70 | { accessor => 'multi' } |
71 | ); |
72 | |
73 | DBICTest::Schema::Tag->add_relationship( |
74 | cd => 'DBICTest::Schema::CD', |
b3e8ac9b |
75 | { 'foreign.cdid' => 'self.cd' }, |
76 | { accessor => 'single' } |
0567538f |
77 | ); |
78 | |
79 | DBICTest::Schema::Track->add_relationship( |
80 | cd => 'DBICTest::Schema::CD', |
35c2ee73 |
81 | { 'foreign.cdid' => 'self.cd' } |
0567538f |
82 | ); |
83 | |
84 | DBICTest::Schema::TwoKeys->add_relationship( |
85 | artist => 'DBICTest::Schema::Artist', |
86 | { 'foreign.artistid' => 'self.artist' } |
87 | ); |
88 | DBICTest::Schema::TwoKeys->add_relationship( |
89 | cd => 'DBICTest::Schema::CD', |
90 | { 'foreign.cdid' => 'self.cd' } |
91 | ); |
92 | |
7411204b |
93 | DBICTest::Schema::CD_to_Producer->add_relationship( |
94 | cd => 'DBICTest::Schema::CD', |
95 | { 'foreign.cdid' => 'self.cd' } |
96 | ); |
97 | DBICTest::Schema::CD_to_Producer->add_relationship( |
98 | producer => 'DBICTest::Schema::Producer', |
99 | { 'foreign.producerid' => 'self.producer' } |
100 | ); |
101 | |
102 | # now the Helpers |
103 | DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer'); |
0f6ac8bb |
104 | DBICTest::Schema::CD->many_to_many( 'producers_sorted', 'cd_to_producer', 'producer', { order_by => 'producer.name' }); |
7411204b |
105 | |
0567538f |
106 | 1; |