a3e7279bcac1f84155ccba63c07a02bf2543a245
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / BasicRels.pm
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' },
8     { order_by => 'year', join_type => 'LEFT', cascade_delete => 1 }
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 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 );
27 DBICTest::Schema::CD->add_relationship(
28     artist => 'DBICTest::Schema::Artist',
29     { 'foreign.artistid' => 'self.artist' },
30     { accessor => 'filter' },
31 );
32 DBICTest::Schema::CD->add_relationship(
33     tracks => 'DBICTest::Schema::Track',
34     { 'foreign.cd' => 'self.cdid' },
35     { join_type => 'LEFT', cascade_delete => 1 }
36 );
37 DBICTest::Schema::CD->add_relationship(
38     tags => 'DBICTest::Schema::Tag',
39     { 'foreign.cd' => 'self.cdid' },
40     { join_type => 'LEFT', cascade_delete => 1 }
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' },
46     { join_type => 'LEFT', accessor => 'single' }
47 );
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 );
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',
74     { 'foreign.cdid' => 'self.cd' }
75 );
76
77 DBICTest::Schema::Track->add_relationship(
78     cd => 'DBICTest::Schema::CD',
79     { 'foreign.cdid' => 'self.cd' }
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
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
103 1;