Multi-step prefetch (all except _construct_object changes by Will Hawes)
[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     { accessor => 'single' }
76 );
77
78 DBICTest::Schema::Track->add_relationship(
79     cd => 'DBICTest::Schema::CD',
80     { 'foreign.cdid' => 'self.cd' }
81 );
82
83 DBICTest::Schema::TwoKeys->add_relationship(
84     artist => 'DBICTest::Schema::Artist',
85     { 'foreign.artistid' => 'self.artist' }
86 );
87 DBICTest::Schema::TwoKeys->add_relationship(
88     cd => 'DBICTest::Schema::CD',
89     { 'foreign.cdid' => 'self.cd' }
90 );
91
92 DBICTest::Schema::CD_to_Producer->add_relationship(
93     cd => 'DBICTest::Schema::CD',
94     { 'foreign.cdid' => 'self.cd' }
95 );
96 DBICTest::Schema::CD_to_Producer->add_relationship(
97     producer => 'DBICTest::Schema::Producer',
98     { 'foreign.producerid' => 'self.producer' }
99 );
100
101 # now the Helpers
102 DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer');
103
104 1;