added cascade_copy relationship attribute
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / HelperRels.pm
CommitLineData
7411204b 1package DBICTest::Schema::HelperRels;
0567538f 2
3use base 'DBIx::Class::Core';
4
07037f89 5DBICTest::Schema::Artist->has_many(cds => 'DBICTest::Schema::CD', undef,
6 { order_by => 'year' });
7DBICTest::Schema::Artist->has_many(twokeys => 'DBICTest::Schema::TwoKeys');
8DBICTest::Schema::Artist->has_many(onekeys => 'DBICTest::Schema::OneKey');
0567538f 9
07037f89 10DBICTest::Schema::CD->belongs_to('artist', 'DBICTest::Schema::Artist');
0567538f 11
07037f89 12DBICTest::Schema::CD->has_many(tracks => 'DBICTest::Schema::Track');
13DBICTest::Schema::CD->has_many(tags => 'DBICTest::Schema::Tag');
7411204b 14DBICTest::Schema::CD->has_many(cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd');
0567538f 15
503536d5 16DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes',
17 undef, { proxy => [ qw/notes/ ] });
0567538f 18
07037f89 19DBICTest::Schema::SelfRefAlias->belongs_to(
20 self_ref => 'DBICTest::Schema::SelfRef');
07037f89 21DBICTest::Schema::SelfRefAlias->belongs_to(
22 alias => 'DBICTest::Schema::SelfRef');
0567538f 23
07037f89 24DBICTest::Schema::SelfRef->has_many(
25 aliases => 'DBICTest::Schema::SelfRefAlias' => 'self_ref');
0567538f 26
07037f89 27DBICTest::Schema::Tag->belongs_to('cd', 'DBICTest::Schema::CD');
28
b8777a0d 29DBICTest::Schema::Track->belongs_to('cd', 'DBICTest::Schema::CD');
1e3bc087 30DBICTest::Schema::Track->belongs_to('disc', 'DBICTest::Schema::CD', 'cd');
07037f89 31
32DBICTest::Schema::TwoKeys->belongs_to('artist', 'DBICTest::Schema::Artist');
07037f89 33DBICTest::Schema::TwoKeys->belongs_to('cd', 'DBICTest::Schema::CD');
0567538f 34
5efe4c79 35DBICTest::Schema::CD_to_Producer->belongs_to(
36 'cd', 'DBICTest::Schema::CD',
37 { 'foreign.cdid' => 'self.cd' }
38);
39DBICTest::Schema::CD_to_Producer->belongs_to(
40 'producer', 'DBICTest::Schema::Producer',
41 { 'foreign.producerid' => 'self.producer' }
42);
43DBICTest::Schema::Artist->has_many(
44 'artist_undirected_maps', 'DBICTest::Schema::ArtistUndirectedMap',
333cce60 45 [{'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'}],
46 { cascade_copy => 0 } # this would *so* not make sense
5efe4c79 47);
48DBICTest::Schema::ArtistUndirectedMap->belongs_to(
49 'artist1', 'DBICTest::Schema::Artist', 'id1');
50DBICTest::Schema::ArtistUndirectedMap->belongs_to(
51 'artist2', 'DBICTest::Schema::Artist', 'id2');
52DBICTest::Schema::ArtistUndirectedMap->has_many(
53 'mapped_artists', 'DBICTest::Schema::Artist',
54 [{'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'}]);
7411204b 55
56# now the Helpers
57DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer');
0f6ac8bb 58DBICTest::Schema::CD->many_to_many( 'producers_sorted', 'cd_to_producer', 'producer', { order_by => 'producer.name' });
7411204b 59
0567538f 601;