1 package # hide from PAUSE
4 use base qw/DBICTest::BaseResult/;
6 __PACKAGE__->table('cd');
7 __PACKAGE__->add_columns(
9 data_type => 'integer',
10 is_auto_increment => 1,
13 data_type => 'integer',
16 data_type => 'varchar',
20 data_type => 'varchar',
24 data_type => 'integer',
28 data_type => 'integer',
33 __PACKAGE__->set_primary_key('cdid');
34 __PACKAGE__->add_unique_constraint([ qw/artist title/ ]);
36 __PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist', undef, {
40 # in case this is a single-cd it promotes a track from another cd
41 __PACKAGE__->belongs_to( single_track => 'DBICTest::Schema::Track', 'single_track',
42 { join_type => 'left'}
45 __PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track' );
46 __PACKAGE__->has_many(
47 tags => 'DBICTest::Schema::Tag', undef,
48 { order_by => 'tag' },
50 __PACKAGE__->has_many(
51 cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd'
54 __PACKAGE__->might_have(
55 liner_notes => 'DBICTest::Schema::LinerNotes', undef,
56 { proxy => [ qw/notes/ ] },
58 __PACKAGE__->might_have(artwork => 'DBICTest::Schema::Artwork', 'cd_id');
60 __PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' );
61 __PACKAGE__->many_to_many(
62 producers_sorted => cd_to_producer => 'producer',
63 { order_by => 'producer.name' },
66 __PACKAGE__->belongs_to('genre', 'DBICTest::Schema::Genre',
67 { 'foreign.genreid' => 'self.genreid' },
70 on_delete => 'SET NULL',
71 on_update => 'CASCADE',
75 #This second relationship was added to test the short-circuiting of pointless
76 #queries provided by undef_on_null_fk. the relevant test in 66relationship.t
77 __PACKAGE__->belongs_to('genre_inefficient', 'DBICTest::Schema::Genre',
78 { 'foreign.genreid' => 'self.genreid' },
81 on_delete => 'SET NULL',
82 on_update => 'CASCADE',
83 undef_on_null_fk => 0,