Hack around a stupid SQL::Abstract bug and add GROUP BY support
[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
19 DBICTest::Schema::CD->add_relationship(
20     artist => 'DBICTest::Schema::Artist',
21     { 'foreign.artistid' => 'self.artist' },
22 );
23 DBICTest::Schema::CD->add_relationship(
24     tracks => 'DBICTest::Schema::Track',
25     { 'foreign.cd' => 'self.cdid' },
26     { join_type => 'LEFT', cascade_delete => 1 }
27 );
28 DBICTest::Schema::CD->add_relationship(
29     tags => 'DBICTest::Schema::Tag',
30     { 'foreign.cd' => 'self.cdid' },
31     { join_type => 'LEFT', cascade_delete => 1 }
32 );
33 #DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes' => qw/notes/);
34 DBICTest::Schema::CD->add_relationship(
35     liner_notes => 'DBICTest::Schema::LinerNotes',
36     { 'foreign.liner_id' => 'self.cdid' },
37     { join_type => 'LEFT' }
38 );
39
40
41 DBICTest::Schema::SelfRefAlias->add_relationship(
42     self_ref => 'DBICTest::Schema::SelfRef',
43     { 'foreign.id' => 'self.self_ref' },
44     { accessor     => 'single' }
45
46 );
47 DBICTest::Schema::SelfRefAlias->add_relationship(
48     alias => 'DBICTest::Schema::SelfRef',
49     { 'foreign.id' => 'self.alias' },
50     { accessor     => 'single' }
51 );
52
53 DBICTest::Schema::SelfRef->add_relationship(
54     aliases => 'DBICTest::Schema::SelfRefAlias',
55     { 'foreign.self_ref' => 'self.id' },
56     { accessor => 'multi' }
57 );
58
59 DBICTest::Schema::Tag->add_relationship(
60     cd => 'DBICTest::Schema::CD',
61     { 'foreign.cdid' => 'self.cd' }
62 );
63
64 DBICTest::Schema::Track->add_relationship(
65     cd => 'DBICTest::Schema::CD',
66     { 'foreign.cdid' => 'self.cd' }
67 );
68
69 DBICTest::Schema::TwoKeys->add_relationship(
70     artist => 'DBICTest::Schema::Artist',
71     { 'foreign.artistid' => 'self.artist' }
72 );
73 DBICTest::Schema::TwoKeys->add_relationship(
74     cd => 'DBICTest::Schema::CD',
75     { 'foreign.cdid' => 'self.cd' }
76 );
77
78 1;