Introduce 'any_null_means_no_value' option to eliminate wasteful queries. The option...
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / CD.pm
CommitLineData
c6d74d3e 1package # hide from PAUSE
2 DBICTest::Schema::CD;
a02675cd 3
4use base 'DBIx::Class::Core';
5
ff657a43 6__PACKAGE__->table('cd');
7__PACKAGE__->add_columns(
0009fa49 8 'cdid' => {
9 data_type => 'integer',
10 is_auto_increment => 1,
11 },
12 'artist' => {
13 data_type => 'integer',
14 },
15 'title' => {
16 data_type => 'varchar',
cb561d1a 17 size => 100,
0009fa49 18 },
19 'year' => {
20 data_type => 'varchar',
cb561d1a 21 size => 100,
0009fa49 22 },
370f2ba2 23 'genreid' => {
4e0eaf64 24 data_type => 'integer',
25 is_nullable => 1,
a1cb5921 26 },
27 'single_track' => {
28 data_type => 'integer',
29 is_nullable => 1,
30 is_foreign_key => 1,
370f2ba2 31 }
0009fa49 32);
ff657a43 33__PACKAGE__->set_primary_key('cdid');
368a5228 34__PACKAGE__->add_unique_constraint([ qw/artist title/ ]);
ff657a43 35
e377d723 36__PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist', undef, {
37 is_deferrable => 1,
e377d723 38});
ff657a43 39
a1cb5921 40# in case this is a single-cd it promotes a track from another cd
41__PACKAGE__->belongs_to( single_track => 'DBICTest::Schema::Track' );
42
ff657a43 43__PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track' );
44__PACKAGE__->has_many(
45 tags => 'DBICTest::Schema::Tag', undef,
46 { order_by => 'tag' },
47);
48__PACKAGE__->has_many(
49 cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd'
50);
51
52__PACKAGE__->might_have(
53 liner_notes => 'DBICTest::Schema::LinerNotes', undef,
54 { proxy => [ qw/notes/ ] },
55);
4f6386b0 56__PACKAGE__->might_have(artwork => 'DBICTest::Schema::Artwork', 'cd_id');
57
ff657a43 58__PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' );
59__PACKAGE__->many_to_many(
60 producers_sorted => cd_to_producer => 'producer',
61 { order_by => 'producer.name' },
62);
a02675cd 63
87310237 64__PACKAGE__->belongs_to('genre', 'DBICTest::Schema::Genre',
65 { 'foreign.genreid' => 'self.genreid' },
a0dd8679 66 {
67 join_type => 'left',
68 on_delete => 'SET NULL',
69 on_update => 'CASCADE',
c89815db 70 any_null_means_no_value => 1,
a0dd8679 71 },
87310237 72);
370f2ba2 73
74#__PACKAGE__->add_relationship('genre', 'DBICTest::Schema::Genre',
75# { 'foreign.genreid' => 'self.genreid' },
76# { 'accessor' => 'single' }
77#);
78
a02675cd 791;