1package # hide from PAUSE 2 DBICTest::Schema::CD; 3 4use base qw/DBICTest::BaseResult/; 5 6# this tests table name as scalar ref 7# DO NOT REMOVE THE \ 8__PACKAGE__->table(\'cd'); 9 10__PACKAGE__->add_columns( 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', 20 size => 100, 21 }, 22 'year' => { 23 data_type => 'varchar', 24 size => 100, 25 }, 26 'genreid' => { 27 data_type => 'integer', 28 is_nullable => 1, 29 accessor => undef, 30 }, 31 'single_track' => { 32 data_type => 'integer', 33 is_nullable => 1, 34 is_foreign_key => 1, 35 } 36); 37__PACKAGE__->set_primary_key('cdid'); 38__PACKAGE__->add_unique_constraint([ qw/artist title/ ]); 39 40__PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist', undef, { 41 is_deferrable => 1, 42}); 43 44# in case this is a single-cd it promotes a track from another cd 45__PACKAGE__->belongs_to( single_track => 'DBICTest::Schema::Track', 'single_track', 46 { join_type => 'left'} 47); 48 49__PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track' ); 50__PACKAGE__->has_many( 51 tags => 'DBICTest::Schema::Tag', undef, 52 { order_by => 'tag' }, 53); 54__PACKAGE__->has_many( 55 cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd' 56); 57 58__PACKAGE__->might_have( 59 liner_notes => 'DBICTest::Schema::LinerNotes', undef, 60 { proxy => [ qw/notes/ ] }, 61); 62__PACKAGE__->might_have(artwork => 'DBICTest::Schema::Artwork', 'cd_id'); 63__PACKAGE__->has_one(mandatory_artwork => 'DBICTest::Schema::Artwork', 'cd_id'); 64 65__PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' ); 66__PACKAGE__->many_to_many( 67 producers_sorted => cd_to_producer => 'producer', 68 { order_by => 'producer.name' }, 69); 70 71__PACKAGE__->belongs_to('genre', 'DBICTest::Schema::Genre', 72 { 'foreign.genreid' => 'self.genreid' }, 73 { 74 join_type => 'left', 75 on_delete => 'SET NULL', 76 on_update => 'CASCADE', 77 }, 78); 79 80#This second relationship was added to test the short-circuiting of pointless 81#queries provided by undef_on_null_fk. the relevant test in 66relationship.t 82__PACKAGE__->belongs_to('genre_inefficient', 'DBICTest::Schema::Genre', 83 { 'foreign.genreid' => 'self.genreid' }, 84 { 85 join_type => 'left', 86 on_delete => 'SET NULL', 87 on_update => 'CASCADE', 88 undef_on_null_fk => 0, 89 }, 90); 91 921; 93