Yet another test relationship/table for the real test by castaway
Peter Rabbitson [Sun, 23 Nov 2008 12:50:46 +0000 (12:50 +0000)]
t/99dbic_sqlt_parser.t
t/lib/DBICTest/Schema.pm
t/lib/DBICTest/Schema/Artist.pm
t/lib/DBICTest/Schema/Artwork.pm
t/lib/DBICTest/Schema/Artwork_to_Artist.pm [new file with mode: 0644]
t/lib/sqlite.sql

index bbac5e3..eac9edd 100644 (file)
@@ -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();
index d217e47..d683a25 100644 (file)
@@ -21,6 +21,7 @@ __PACKAGE__->load_classes(qw/
   { 'DBICTest::Schema' => [qw/
     LinerNotes
     Artwork
+    Artwork_to_Artist
     Image
     Lyrics
     LyricVersion
index c772c5b..3b7f8ea 100644 (file)
@@ -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) = @_;
 
index f6e00d2..10e07ce 100644 (file)
@@ -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 (file)
index 0000000..0d832ca
--- /dev/null
@@ -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;
index fcdae19..4122015 100644 (file)
@@ -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 (