Improved join condition possiblities - arrayrefs of hashrefs now work for OR
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / BasicRels.pm
CommitLineData
0567538f 1package DBICTest::Schema::BasicRels;
2
3use base 'DBIx::Class::Core';
4
5DBICTest::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);
10DBICTest::Schema::Artist->add_relationship(
11 twokeys => 'DBICTest::Schema::TwoKeys',
12 { 'foreign.artist' => 'self.artistid' }
13);
14DBICTest::Schema::Artist->add_relationship(
15 onekeys => 'DBICTest::Schema::OneKey',
16 { 'foreign.artist' => 'self.artistid' }
17);
5efe4c79 18DBICTest::Schema::Artist->add_relationship(
19 artist_undirected_maps => 'DBICTest::Schema::ArtistUndirectedMap',
20 [{'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'}],
21 { accessor => 'multi' }
22);
23DBICTest::Schema::ArtistUndirectedMap->add_relationship(
24 'mapped_artists', 'DBICTest::Schema::Artist',
25 [{'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'}]
26);
0567538f 27DBICTest::Schema::CD->add_relationship(
28 artist => 'DBICTest::Schema::Artist',
29 { 'foreign.artistid' => 'self.artist' },
8452e496 30 { accessor => 'filter' },
0567538f 31);
32DBICTest::Schema::CD->add_relationship(
33 tracks => 'DBICTest::Schema::Track',
54540863 34 { 'foreign.cd' => 'self.cdid' },
35 { join_type => 'LEFT', cascade_delete => 1 }
0567538f 36);
37DBICTest::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/);
43DBICTest::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 48DBICTest::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
54DBICTest::Schema::SelfRefAlias->add_relationship(
55 self_ref => 'DBICTest::Schema::SelfRef',
56 { 'foreign.id' => 'self.self_ref' },
57 { accessor => 'single' }
58
59);
60DBICTest::Schema::SelfRefAlias->add_relationship(
61 alias => 'DBICTest::Schema::SelfRef',
62 { 'foreign.id' => 'self.alias' },
63 { accessor => 'single' }
64);
65
66DBICTest::Schema::SelfRef->add_relationship(
67 aliases => 'DBICTest::Schema::SelfRefAlias',
68 { 'foreign.self_ref' => 'self.id' },
69 { accessor => 'multi' }
70);
71
72DBICTest::Schema::Tag->add_relationship(
73 cd => 'DBICTest::Schema::CD',
74 { 'foreign.cdid' => 'self.cd' }
75);
76
77DBICTest::Schema::Track->add_relationship(
78 cd => 'DBICTest::Schema::CD',
79 { 'foreign.cdid' => 'self.cd' }
80);
81
82DBICTest::Schema::TwoKeys->add_relationship(
83 artist => 'DBICTest::Schema::Artist',
84 { 'foreign.artistid' => 'self.artist' }
85);
86DBICTest::Schema::TwoKeys->add_relationship(
87 cd => 'DBICTest::Schema::CD',
88 { 'foreign.cdid' => 'self.cd' }
89);
90
7411204b 91DBICTest::Schema::CD_to_Producer->add_relationship(
92 cd => 'DBICTest::Schema::CD',
93 { 'foreign.cdid' => 'self.cd' }
94);
95DBICTest::Schema::CD_to_Producer->add_relationship(
96 producer => 'DBICTest::Schema::Producer',
97 { 'foreign.producerid' => 'self.producer' }
98);
99
100# now the Helpers
101DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer');
102
0567538f 1031;