Fixes to pg test after review:
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / CD.pm
CommitLineData
c6d74d3e 1package # hide from PAUSE
2 DBICTest::Schema::CD;
a02675cd 3
660cf1be 4use base qw/DBICTest::BaseResult/;
a02675cd 5
cebb7cce 6# this tests table name as scalar ref
7# DO NOT REMOVE THE \
8__PACKAGE__->table(\'cd');
9
ff657a43 10__PACKAGE__->add_columns(
0009fa49 11 'cdid' => {
12 data_type => 'integer',
13 is_auto_increment => 1,
14 },
15 'artist' => {
16 data_type => 'integer',
17 },
18 'title' => {
19 data_type => 'varchar',
cb561d1a 20 size => 100,
0009fa49 21 },
22 'year' => {
23 data_type => 'varchar',
cb561d1a 24 size => 100,
0009fa49 25 },
370f2ba2 26 'genreid' => {
4e0eaf64 27 data_type => 'integer',
28 is_nullable => 1,
a1cb5921 29 },
30 'single_track' => {
31 data_type => 'integer',
32 is_nullable => 1,
33 is_foreign_key => 1,
370f2ba2 34 }
0009fa49 35);
ff657a43 36__PACKAGE__->set_primary_key('cdid');
368a5228 37__PACKAGE__->add_unique_constraint([ qw/artist title/ ]);
ff657a43 38
e377d723 39__PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist', undef, {
40 is_deferrable => 1,
e377d723 41});
ff657a43 42
a1cb5921 43# in case this is a single-cd it promotes a track from another cd
56b73f83 44__PACKAGE__->belongs_to( single_track => 'DBICTest::Schema::Track', 'single_track',
45 { join_type => 'left'}
46);
a1cb5921 47
ff657a43 48__PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track' );
49__PACKAGE__->has_many(
50 tags => 'DBICTest::Schema::Tag', undef,
51 { order_by => 'tag' },
52);
53__PACKAGE__->has_many(
54 cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd'
55);
56
57__PACKAGE__->might_have(
58 liner_notes => 'DBICTest::Schema::LinerNotes', undef,
59 { proxy => [ qw/notes/ ] },
60);
4f6386b0 61__PACKAGE__->might_have(artwork => 'DBICTest::Schema::Artwork', 'cd_id');
cc9d96d0 62__PACKAGE__->has_one(mandatory_artwork => 'DBICTest::Schema::Artwork', 'cd_id');
4f6386b0 63
ff657a43 64__PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' );
65__PACKAGE__->many_to_many(
66 producers_sorted => cd_to_producer => 'producer',
67 { order_by => 'producer.name' },
68);
a02675cd 69
87310237 70__PACKAGE__->belongs_to('genre', 'DBICTest::Schema::Genre',
71 { 'foreign.genreid' => 'self.genreid' },
a0dd8679 72 {
73 join_type => 'left',
74 on_delete => 'SET NULL',
75 on_update => 'CASCADE',
a0dd8679 76 },
87310237 77);
370f2ba2 78
cef1bdda 79#This second relationship was added to test the short-circuiting of pointless
80#queries provided by undef_on_null_fk. the relevant test in 66relationship.t
81__PACKAGE__->belongs_to('genre_inefficient', 'DBICTest::Schema::Genre',
82 { 'foreign.genreid' => 'self.genreid' },
83 {
84 join_type => 'left',
85 on_delete => 'SET NULL',
86 on_update => 'CASCADE',
87 undef_on_null_fk => 0,
88 },
89);
90
a02675cd 911;