From: Peter Rabbitson Date: Fri, 24 Oct 2008 13:23:33 +0000 (+0000) Subject: More test schema relations for future tests X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=87310237f099566ca0446d7f392b951e8eb40b0c;p=dbsrgits%2FDBIx-Class-Historic.git More test schema relations for future tests --- diff --git a/t/lib/DBICTest/Schema/CD.pm b/t/lib/DBICTest/Schema/CD.pm index 76b0372..d121027 100644 --- a/t/lib/DBICTest/Schema/CD.pm +++ b/t/lib/DBICTest/Schema/CD.pm @@ -53,7 +53,10 @@ __PACKAGE__->many_to_many( { order_by => 'producer.name' }, ); -__PACKAGE__->belongs_to('genre', 'DBICTest::Schema::Genre', { 'foreign.genreid' => 'self.genreid' }); +__PACKAGE__->belongs_to('genre', 'DBICTest::Schema::Genre', + { 'foreign.genreid' => 'self.genreid' }, + { join_type => 'left' }, +); #__PACKAGE__->add_relationship('genre', 'DBICTest::Schema::Genre', # { 'foreign.genreid' => 'self.genreid' }, diff --git a/t/lib/DBICTest/Schema/CD_to_Producer.pm b/t/lib/DBICTest/Schema/CD_to_Producer.pm index 117a590..cf18c4e 100644 --- a/t/lib/DBICTest/Schema/CD_to_Producer.pm +++ b/t/lib/DBICTest/Schema/CD_to_Producer.pm @@ -17,7 +17,8 @@ __PACKAGE__->belongs_to( __PACKAGE__->belongs_to( 'producer', 'DBICTest::Schema::Producer', - { 'foreign.producerid' => 'self.producer' } + { 'foreign.producerid' => 'self.producer' }, + { on_delete => undef, on_update => undef }, ); 1; diff --git a/t/lib/DBICTest/Schema/Genre.pm b/t/lib/DBICTest/Schema/Genre.pm index e72cd93..db2ca9c 100644 --- a/t/lib/DBICTest/Schema/Genre.pm +++ b/t/lib/DBICTest/Schema/Genre.pm @@ -5,18 +5,19 @@ use strict; use base 'DBIx::Class::Core'; __PACKAGE__->table('genre'); -__PACKAGE__->add_columns(qw/genreid name/); +__PACKAGE__->add_columns( + genreid => { + data_type => 'integer', + is_auto_increment => 1, + }, + name => { + data_type => 'varchar', + size => 100, + }, +); __PACKAGE__->set_primary_key('genreid'); +__PACKAGE__->add_unique_constraint ( genre_name => [qw/name/] ); -1; -package DBICTest::Schema::Genre; - -use strict; - -use base 'DBIx::Class::Core'; - -__PACKAGE__->table('genre'); -__PACKAGE__->add_columns(qw/genreid name/); -__PACKAGE__->set_primary_key('genreid'); +__PACKAGE__->has_many (cds => 'DBICTest::Schema::CD', 'genreid'); 1; diff --git a/t/lib/DBICTest/Schema/Producer.pm b/t/lib/DBICTest/Schema/Producer.pm index 036f9f2..26e140e 100644 --- a/t/lib/DBICTest/Schema/Producer.pm +++ b/t/lib/DBICTest/Schema/Producer.pm @@ -17,4 +17,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key('producerid'); __PACKAGE__->add_unique_constraint(prod_name => [ qw/name/ ]); +__PACKAGE__->has_many( + producer_to_cd => 'DBICTest::Schema::CD_to_Producer' => 'producer' +); + 1; diff --git a/t/lib/sqlite.sql b/t/lib/sqlite.sql index 15967b3..d0e0bfd 100644 --- a/t/lib/sqlite.sql +++ b/t/lib/sqlite.sql @@ -1,6 +1,6 @@ -- -- Created by SQL::Translator::Producer::SQLite --- Created on Thu Oct 9 13:44:56 2008 +-- Created on Fri Oct 24 14:20:32 2008 -- BEGIN TRANSACTION; @@ -171,11 +171,11 @@ CREATE INDEX fourkeys_to_twokeys_idx_t_artist_t_cd_fourkeys_to ON fourkeys_to_tw -- Table: genre -- CREATE TABLE genre ( - genreid NOT NULL, - name NOT NULL, - PRIMARY KEY (genreid) + genreid INTEGER PRIMARY KEY NOT NULL, + name varchar(100) NOT NULL ); +CREATE UNIQUE INDEX genre_name_genre ON genre (name); -- -- Table: liner_notes