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');
59 __PACKAGE__->has_one(mandatory_artwork => 'DBICTest::Schema::Artwork', 'cd_id');
61 __PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' );
62 __PACKAGE__->many_to_many(
63 producers_sorted => cd_to_producer => 'producer',
64 { order_by => 'producer.name' },
67 __PACKAGE__->belongs_to('genre', 'DBICTest::Schema::Genre',
68 { 'foreign.genreid' => 'self.genreid' },
71 on_delete => 'SET NULL',
72 on_update => 'CASCADE',
76 #This second relationship was added to test the short-circuiting of pointless
77 #queries provided by undef_on_null_fk. the relevant test in 66relationship.t
78 __PACKAGE__->belongs_to('genre_inefficient', 'DBICTest::Schema::Genre',
79 { 'foreign.genreid' => 'self.genreid' },
82 on_delete => 'SET NULL',
83 on_update => 'CASCADE',
84 undef_on_null_fk => 0,