From: Aran Deltac Date: Wed, 24 May 2006 19:50:31 +0000 (+0000) Subject: Move relationships out of Relationships.pm and in to the respective classes. Removed... X-Git-Tag: v0.07002~75^2~165^2~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ff657a4317312f9fc858e128affaf97aa46c336b;p=dbsrgits%2FDBIx-Class.git Move relationships out of Relationships.pm and in to the respective classes. Removed references to PK::Auto. --- diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index f4c6706..0bb49c4 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -3,10 +3,8 @@ package # hide from PAUSE use base 'DBIx::Class::Core'; -__PACKAGE__->load_components('PK::Auto'); - -DBICTest::Schema::Artist->table('artist'); -DBICTest::Schema::Artist->add_columns( +__PACKAGE__->table('artist'); +__PACKAGE__->add_columns( 'artistid' => { data_type => 'integer', is_auto_increment => 1 @@ -17,11 +15,25 @@ DBICTest::Schema::Artist->add_columns( is_nullable => 1, }, ); -DBICTest::Schema::Artist->set_primary_key('artistid'); +__PACKAGE__->set_primary_key('artistid'); __PACKAGE__->mk_classdata('field_name_for', { artistid => 'primary key', name => 'artist name', }); +__PACKAGE__->has_many( + cds => 'DBICTest::Schema::CD', undef, + { order_by => 'year' }, +); + +__PACKAGE__->has_many( twokeys => 'DBICTest::Schema::TwoKeys' ); +__PACKAGE__->has_many( onekeys => 'DBICTest::Schema::OneKey' ); + +__PACKAGE__->has_many( + artist_undirected_maps => 'DBICTest::Schema::ArtistUndirectedMap', + [ {'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'} ], + { cascade_copy => 0 } # this would *so* not make sense +); + 1; diff --git a/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm b/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm index 6e888ed..2669575 100644 --- a/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm +++ b/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm @@ -10,4 +10,11 @@ __PACKAGE__->add_columns( ); __PACKAGE__->set_primary_key(qw/id1 id2/); +__PACKAGE__->belongs_to( 'artist1', 'DBICTest::Schema::Artist', 'id1' ); +__PACKAGE__->belongs_to( 'artist2', 'DBICTest::Schema::Artist', 'id2'); +__PACKAGE__->has_many( + 'mapped_artists', 'DBICTest::Schema::Artist', + [ {'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'} ], +); + 1; diff --git a/t/lib/DBICTest/Schema/Bookmark.pm b/t/lib/DBICTest/Schema/Bookmark.pm index 4f9ec44..72db586 100644 --- a/t/lib/DBICTest/Schema/Bookmark.pm +++ b/t/lib/DBICTest/Schema/Bookmark.pm @@ -7,7 +7,6 @@ package # hide from PAUSE use strict; use warnings; -__PACKAGE__->load_components(qw/PK::Auto Core/); __PACKAGE__->table('bookmark'); __PACKAGE__->add_columns(qw/id link/); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/CD.pm b/t/lib/DBICTest/Schema/CD.pm index 90e4c0c..262d23f 100644 --- a/t/lib/DBICTest/Schema/CD.pm +++ b/t/lib/DBICTest/Schema/CD.pm @@ -3,10 +3,8 @@ package # hide from PAUSE use base 'DBIx::Class::Core'; -__PACKAGE__->load_components('PK::Auto'); - -DBICTest::Schema::CD->table('cd'); -DBICTest::Schema::CD->add_columns( +__PACKAGE__->table('cd'); +__PACKAGE__->add_columns( 'cdid' => { data_type => 'integer', is_auto_increment => 1, @@ -23,7 +21,28 @@ DBICTest::Schema::CD->add_columns( size => 100, }, ); -DBICTest::Schema::CD->set_primary_key('cdid'); -DBICTest::Schema::CD->add_unique_constraint(artist_title => [ qw/artist title/ ]); +__PACKAGE__->set_primary_key('cdid'); +__PACKAGE__->add_unique_constraint(artist_title => [ qw/artist title/ ]); + +__PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist' ); + +__PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track' ); +__PACKAGE__->has_many( + tags => 'DBICTest::Schema::Tag', undef, + { order_by => 'tag' }, +); +__PACKAGE__->has_many( + cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd' +); + +__PACKAGE__->might_have( + liner_notes => 'DBICTest::Schema::LinerNotes', undef, + { proxy => [ qw/notes/ ] }, +); +__PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' ); +__PACKAGE__->many_to_many( + producers_sorted => cd_to_producer => 'producer', + { order_by => 'producer.name' }, +); 1; diff --git a/t/lib/DBICTest/Schema/CD_to_Producer.pm b/t/lib/DBICTest/Schema/CD_to_Producer.pm index 378c58c..117a590 100644 --- a/t/lib/DBICTest/Schema/CD_to_Producer.pm +++ b/t/lib/DBICTest/Schema/CD_to_Producer.pm @@ -10,4 +10,14 @@ __PACKAGE__->add_columns( ); __PACKAGE__->set_primary_key(qw/cd producer/); +__PACKAGE__->belongs_to( + 'cd', 'DBICTest::Schema::CD', + { 'foreign.cdid' => 'self.cd' } +); + +__PACKAGE__->belongs_to( + 'producer', 'DBICTest::Schema::Producer', + { 'foreign.producerid' => 'self.producer' } +); + 1; diff --git a/t/lib/DBICTest/Schema/Employee.pm b/t/lib/DBICTest/Schema/Employee.pm index e91f872..78b3d16 100644 --- a/t/lib/DBICTest/Schema/Employee.pm +++ b/t/lib/DBICTest/Schema/Employee.pm @@ -1,9 +1,9 @@ package # hide from PAUSE DBICTest::Schema::Employee; -use base 'DBIx::Class'; +use base 'DBIx::Class::Core'; -__PACKAGE__->load_components(qw( Ordered PK::Auto Core )); +__PACKAGE__->load_components(qw( Ordered )); __PACKAGE__->table('employee'); diff --git a/t/lib/DBICTest/Schema/Event.pm b/t/lib/DBICTest/Schema/Event.pm index fea3b07..937d782 100644 --- a/t/lib/DBICTest/Schema/Event.pm +++ b/t/lib/DBICTest/Schema/Event.pm @@ -2,9 +2,9 @@ package DBICTest::Schema::Event; use strict; use warnings; -use base qw/DBIx::Class/; +use base qw/DBIx::Class::Core/; -__PACKAGE__->load_components(qw/InflateColumn::DateTime PK::Auto Core/); +__PACKAGE__->load_components(qw/InflateColumn::DateTime/); __PACKAGE__->table('event'); diff --git a/t/lib/DBICTest/Schema/Link.pm b/t/lib/DBICTest/Schema/Link.pm index 72574ea..5343122 100644 --- a/t/lib/DBICTest/Schema/Link.pm +++ b/t/lib/DBICTest/Schema/Link.pm @@ -6,7 +6,6 @@ use base 'DBIx::Class::Core'; use strict; use warnings; -__PACKAGE__->load_components(qw/PK::Auto Core/); __PACKAGE__->table('link'); __PACKAGE__->add_columns( 'id' => { diff --git a/t/lib/DBICTest/Schema/OneKey.pm b/t/lib/DBICTest/Schema/OneKey.pm index dbe7003..4cc2918 100644 --- a/t/lib/DBICTest/Schema/OneKey.pm +++ b/t/lib/DBICTest/Schema/OneKey.pm @@ -3,8 +3,6 @@ package # hide from PAUSE use base 'DBIx::Class::Core'; -__PACKAGE__->load_components('PK::Auto'); - DBICTest::Schema::OneKey->table('onekey'); DBICTest::Schema::OneKey->add_columns( 'id' => { diff --git a/t/lib/DBICTest/Schema/Relationships.pm b/t/lib/DBICTest/Schema/Relationships.pm deleted file mode 100644 index a199c88..0000000 --- a/t/lib/DBICTest/Schema/Relationships.pm +++ /dev/null @@ -1,62 +0,0 @@ -package # hide from PAUSE - DBICTest::Schema::Relationships; - -use base 'DBIx::Class::Core'; - -DBICTest::Schema::Artist->has_many(cds => 'DBICTest::Schema::CD', undef, - { order_by => 'year' }); -DBICTest::Schema::Artist->has_many(twokeys => 'DBICTest::Schema::TwoKeys'); -DBICTest::Schema::Artist->has_many(onekeys => 'DBICTest::Schema::OneKey'); - -DBICTest::Schema::CD->belongs_to('artist', 'DBICTest::Schema::Artist'); - -DBICTest::Schema::CD->has_many(tracks => 'DBICTest::Schema::Track'); -DBICTest::Schema::CD->has_many(tags => 'DBICTest::Schema::Tag', undef, - { order_by => 'tag' }); -DBICTest::Schema::CD->has_many(cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd'); - -DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes', - undef, { proxy => [ qw/notes/ ] }); - -DBICTest::Schema::SelfRefAlias->belongs_to( - self_ref => 'DBICTest::Schema::SelfRef'); -DBICTest::Schema::SelfRefAlias->belongs_to( - alias => 'DBICTest::Schema::SelfRef'); - -DBICTest::Schema::SelfRef->has_many( - aliases => 'DBICTest::Schema::SelfRefAlias' => 'self_ref'); - -DBICTest::Schema::Tag->belongs_to('cd', 'DBICTest::Schema::CD'); - -DBICTest::Schema::Track->belongs_to('cd', 'DBICTest::Schema::CD'); -DBICTest::Schema::Track->belongs_to('disc', 'DBICTest::Schema::CD', 'cd'); - -DBICTest::Schema::TwoKeys->belongs_to('artist', 'DBICTest::Schema::Artist'); -DBICTest::Schema::TwoKeys->belongs_to('cd', 'DBICTest::Schema::CD'); - -DBICTest::Schema::CD_to_Producer->belongs_to( - 'cd', 'DBICTest::Schema::CD', - { 'foreign.cdid' => 'self.cd' } -); -DBICTest::Schema::CD_to_Producer->belongs_to( - 'producer', 'DBICTest::Schema::Producer', - { 'foreign.producerid' => 'self.producer' } -); -DBICTest::Schema::Artist->has_many( - 'artist_undirected_maps', 'DBICTest::Schema::ArtistUndirectedMap', - [{'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'}], - { cascade_copy => 0 } # this would *so* not make sense -); -DBICTest::Schema::ArtistUndirectedMap->belongs_to( - 'artist1', 'DBICTest::Schema::Artist', 'id1'); -DBICTest::Schema::ArtistUndirectedMap->belongs_to( - 'artist2', 'DBICTest::Schema::Artist', 'id2'); -DBICTest::Schema::ArtistUndirectedMap->has_many( - 'mapped_artists', 'DBICTest::Schema::Artist', - [{'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'}]); - -# now the Helpers -DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer'); -DBICTest::Schema::CD->many_to_many( 'producers_sorted', 'cd_to_producer', 'producer', { order_by => 'producer.name' }); - -1; diff --git a/t/lib/DBICTest/Schema/SelfRefAlias.pm b/t/lib/DBICTest/Schema/SelfRefAlias.pm index 9d58a8c..d03e7ce 100644 --- a/t/lib/DBICTest/Schema/SelfRefAlias.pm +++ b/t/lib/DBICTest/Schema/SelfRefAlias.pm @@ -14,4 +14,8 @@ __PACKAGE__->add_columns( ); __PACKAGE__->set_primary_key(qw/self_ref alias/); +__PACKAGE__->belongs_to( self_ref => 'DBICTest::Schema::SelfRef' ); +__PACKAGE__->belongs_to( alias => 'DBICTest::Schema::SelfRef' ); +__PACKAGE__->has_many( aliases => 'DBICTest::Schema::SelfRefAlias' => 'self_ref' ); + 1; diff --git a/t/lib/DBICTest/Schema/Tag.pm b/t/lib/DBICTest/Schema/Tag.pm index b93b622..b75c2ef 100644 --- a/t/lib/DBICTest/Schema/Tag.pm +++ b/t/lib/DBICTest/Schema/Tag.pm @@ -3,10 +3,8 @@ package # hide from PAUSE use base qw/DBIx::Class::Core/; -__PACKAGE__->load_components('PK::Auto'); - -DBICTest::Schema::Tag->table('tags'); -DBICTest::Schema::Tag->add_columns( +__PACKAGE__->table('tags'); +__PACKAGE__->add_columns( 'tagid' => { data_type => 'integer', is_auto_increment => 1, @@ -19,6 +17,8 @@ DBICTest::Schema::Tag->add_columns( size => 100, }, ); -DBICTest::Schema::Tag->set_primary_key('tagid'); +__PACKAGE__->set_primary_key('tagid'); + +__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD' ); 1; diff --git a/t/lib/DBICTest/Schema/Track.pm b/t/lib/DBICTest/Schema/Track.pm index 9bbefff..691974a 100644 --- a/t/lib/DBICTest/Schema/Track.pm +++ b/t/lib/DBICTest/Schema/Track.pm @@ -3,8 +3,8 @@ package # hide from PAUSE use base 'DBIx::Class::Core'; -DBICTest::Schema::Track->table('track'); -DBICTest::Schema::Track->add_columns( +__PACKAGE__->table('track'); +__PACKAGE__->add_columns( 'trackid' => { data_type => 'integer', is_auto_increment => 1, @@ -21,6 +21,9 @@ DBICTest::Schema::Track->add_columns( size => 100, }, ); -DBICTest::Schema::Track->set_primary_key('trackid'); +__PACKAGE__->set_primary_key('trackid'); + +__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD' ); +__PACKAGE__->belongs_to( disc => 'DBICTest::Schema::CD' => 'cd'); 1; diff --git a/t/lib/DBICTest/Schema/TreeLike.pm b/t/lib/DBICTest/Schema/TreeLike.pm index 1eca3e1..73f9143 100644 --- a/t/lib/DBICTest/Schema/TreeLike.pm +++ b/t/lib/DBICTest/Schema/TreeLike.pm @@ -1,9 +1,7 @@ package # hide from PAUSE DBICTest::Schema::TreeLike; -use base qw/DBIx::Class/; - -__PACKAGE__->load_components(qw/PK::Auto::SQLite Core/); +use base qw/DBIx::Class::Core/; __PACKAGE__->table('treelike'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/TwoKeys.pm b/t/lib/DBICTest/Schema/TwoKeys.pm index 91a6fef..8483d0b 100755 --- a/t/lib/DBICTest/Schema/TwoKeys.pm +++ b/t/lib/DBICTest/Schema/TwoKeys.pm @@ -3,11 +3,14 @@ package # hide from PAUSE use base 'DBIx::Class::Core'; -DBICTest::Schema::TwoKeys->table('twokeys'); -DBICTest::Schema::TwoKeys->add_columns( +__PACKAGE__->table('twokeys'); +__PACKAGE__->add_columns( 'artist' => { data_type => 'integer' }, 'cd' => { data_type => 'integer' }, ); -DBICTest::Schema::TwoKeys->set_primary_key(qw/artist cd/); +__PACKAGE__->set_primary_key(qw/artist cd/); + +__PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist' ); +__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD' ); 1;