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