From: Peter Rabbitson Date: Sun, 23 Nov 2008 12:50:46 +0000 (+0000) Subject: Yet another test relationship/table for the real test by castaway X-Git-Tag: v0.08240~96^2~11^2~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d563309646cd5a6d156ffb3d601f9d914926831b;p=dbsrgits%2FDBIx-Class.git Yet another test relationship/table for the real test by castaway --- diff --git a/t/99dbic_sqlt_parser.t b/t/99dbic_sqlt_parser.t index bbac5e3..eac9edd 100644 --- a/t/99dbic_sqlt_parser.t +++ b/t/99dbic_sqlt_parser.t @@ -9,7 +9,7 @@ BEGIN { eval "use DBD::mysql; use SQL::Translator 0.09;"; plan $@ ? ( skip_all => 'needs SQL::Translator 0.09 for testing' ) - : ( tests => 114 ); + : ( tests => 117 ); } my $schema = DBICTest->init_schema(); diff --git a/t/lib/DBICTest/Schema.pm b/t/lib/DBICTest/Schema.pm index d217e47..d683a25 100644 --- a/t/lib/DBICTest/Schema.pm +++ b/t/lib/DBICTest/Schema.pm @@ -21,6 +21,7 @@ __PACKAGE__->load_classes(qw/ { 'DBICTest::Schema' => [qw/ LinerNotes Artwork + Artwork_to_Artist Image Lyrics LyricVersion diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index c772c5b..3b7f8ea 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -53,6 +53,12 @@ __PACKAGE__->has_many( { cascade_copy => 0 } # this would *so* not make sense ); +__PACKAGE__->has_many( + artist_to_artwork => 'DBICTest::Schema::Artwork_to_Artist' => 'artist_id' +); +__PACKAGE__->many_to_many('artworks', 'artist_to_artwork', 'artwork'); + + sub sqlt_deploy_hook { my ($self, $sqlt_table) = @_; diff --git a/t/lib/DBICTest/Schema/Artwork.pm b/t/lib/DBICTest/Schema/Artwork.pm index f6e00d2..10e07ce 100644 --- a/t/lib/DBICTest/Schema/Artwork.pm +++ b/t/lib/DBICTest/Schema/Artwork.pm @@ -1,4 +1,4 @@ -package # hide from PAUSE +package # hide from PAUSE DBICTest::Schema::Artwork; use base qw/DBIx::Class::Core/; @@ -13,4 +13,7 @@ __PACKAGE__->set_primary_key('cd_id'); __PACKAGE__->belongs_to('cd', 'DBICTest::Schema::CD', 'cd_id'); __PACKAGE__->has_many('images', 'DBICTest::Schema::Image', 'artwork_id'); +__PACKAGE__->has_many('artwork_to_artist', 'DBICTest::Schema::Artwork_to_Artist', 'artwork_cd_id'); +__PACKAGE__->many_to_many('artists', 'artwork_to_artist', 'artist'); + 1; diff --git a/t/lib/DBICTest/Schema/Artwork_to_Artist.pm b/t/lib/DBICTest/Schema/Artwork_to_Artist.pm new file mode 100644 index 0000000..0d832ca --- /dev/null +++ b/t/lib/DBICTest/Schema/Artwork_to_Artist.pm @@ -0,0 +1,21 @@ +package # hide from PAUSE + DBICTest::Schema::Artwork_to_Artist; + +use base qw/DBIx::Class::Core/; + +__PACKAGE__->table('artwork_to_artist'); +__PACKAGE__->add_columns( + 'artwork_cd_id' => { + data_type => 'integer', + is_foreign_key => 1, + }, + 'artist_id' => { + data_type => 'integer', + is_foreign_key => 1, + }, +); +__PACKAGE__->set_primary_key(qw/artwork_cd_id artist_id/); +__PACKAGE__->belongs_to('artwork', 'DBICTest::Schema::Artwork', 'artwork_cd_id'); +__PACKAGE__->belongs_to('artist', 'DBICTest::Schema::Artist', 'artist_id'); + +1; diff --git a/t/lib/sqlite.sql b/t/lib/sqlite.sql index fcdae19..4122015 100644 --- a/t/lib/sqlite.sql +++ b/t/lib/sqlite.sql @@ -1,6 +1,6 @@ -- -- Created by SQL::Translator::Producer::SQLite --- Created on Mon Nov 17 02:53:11 2008 +-- Created on Sun Nov 23 13:27:13 2008 -- BEGIN TRANSACTION; @@ -38,6 +38,18 @@ CREATE TABLE cd_artwork ( CREATE INDEX cd_artwork_idx_cd_id_cd_artwor ON cd_artwork (cd_id); -- +-- Table: artwork_to_artist +-- +CREATE TABLE artwork_to_artist ( + artwork_cd_id integer NOT NULL, + artist_id integer NOT NULL, + PRIMARY KEY (artwork_cd_id, artist_id) +); + +CREATE INDEX artwork_to_artist_idx_artist_id_artwork_to_arti ON artwork_to_artist (artist_id); +CREATE INDEX artwork_to_artist_idx_artwork_cd_id_artwork_to_ ON artwork_to_artist (artwork_cd_id); + +-- -- Table: bookmark -- CREATE TABLE bookmark (