From: Daniel Westermann-Clark Date: Tue, 8 Aug 2006 06:27:30 +0000 (+0000) Subject: Remove extraneous sources for aliasing test; same effect can be achieved using search... X-Git-Tag: v0.07002~49 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=77211009a2ce3dc56574a59053075c9bb545449a;hp=093fc7a6ef41c585afecfbc3ed18e300e65a1cd5;p=dbsrgits%2FDBIx-Class.git Remove extraneous sources for aliasing test; same effect can be achieved using search_related --- diff --git a/t/64db.t b/t/64db.t index 47aff46..d9c03aa 100644 --- a/t/64db.t +++ b/t/64db.t @@ -41,7 +41,6 @@ my $type_info = $schema->storage->columns_info_for('artist'); delete $type_info->{artistid}{size}; delete $type_info->{name}{size}; -delete $type_info->{agent}{size}; my $test_type_info = { 'artistid' => { @@ -52,10 +51,6 @@ my $test_type_info = { 'data_type' => 'varchar', 'is_nullable' => 0, }, - 'agent' => { - 'data_type' => 'integer', - 'is_nullable' => 0, - }, }; is_deeply($type_info, $test_type_info, 'columns_info_for - column data types'); diff --git a/t/79aliasing.t b/t/79aliasing.t index e0eb04c..6e73f10 100644 --- a/t/79aliasing.t +++ b/t/79aliasing.t @@ -9,34 +9,38 @@ my $schema = DBICTest->init_schema(); plan tests => 8; -my $label = $schema->resultset('Label')->find({ labelid => 1 }); +my $artist = $schema->resultset('Artist')->find(1); # Check that you can leave off the alias { - my $existing_agent = $label->agents->find_or_create({ - name => 'Ted', + my $existing_cd = $artist->search_related('cds', undef, { prefetch => 'tracks' })->find_or_create({ + title => 'Ted', + year => 2006, }); - ok(! $existing_agent->is_changed, 'find_or_create on prefetched has_many with same column names: row is clean'); - is($existing_agent->name, 'Ted', 'find_or_create on prefetched has_many with same column names: name matches existing entry'); + ok(! $existing_cd->is_changed, 'find_or_create on prefetched has_many with same column names: row is clean'); + is($existing_cd->title, 'Ted', 'find_or_create on prefetched has_many with same column names: name matches existing entry'); - my $new_agent = $label->agents->find_or_create({ - name => 'Someone Else', + my $new_cd = $artist->search_related('cds', undef, { prefetch => 'tracks' })->find_or_create({ + title => 'Something Else', + year => 2006, }); - ok(! $new_agent->is_changed, 'find_or_create on prefetched has_many with same column names: row is clean'); - is($new_agent->name, 'Someone Else', 'find_or_create on prefetched has_many with same column names: name matches'); + ok(! $new_cd->is_changed, 'find_or_create on prefetched has_many with same column names: row is clean'); + is($new_cd->title, 'Something Else', 'find_or_create on prefetched has_many with same column names: title matches'); } # Check that you can specify the alias { - my $existing_agent = $label->agents->find_or_create({ - 'me.name' => 'Someone Else', + my $existing_cd = $artist->search_related('cds', undef, { prefetch => 'tracks' })->find_or_create({ + 'me.title' => 'Something Else', + 'me.year' => 2006, }); - ok(! $existing_agent->is_changed, 'find_or_create on prefetched has_many with same column names: row is clean'); - is($existing_agent->name, 'Someone Else', 'find_or_create on prefetched has_many with same column names: can be disambiguated with "me." for existing entry'); + ok(! $existing_cd->is_changed, 'find_or_create on prefetched has_many with same column names: row is clean'); + is($existing_cd->title, 'Something Else', 'find_or_create on prefetched has_many with same column names: can be disambiguated with "me." for existing entry'); - my $new_agent = $label->agents->find_or_create({ - 'me.name' => 'Some New Guy', + my $new_cd = $artist->search_related('cds', undef, { prefetch => 'tracks' })->find_or_create({ + 'me.title' => 'Some New Guy', + 'me.year' => 2006, }); - ok(! $new_agent->is_changed, 'find_or_create on prefetched has_many with same column names: row is clean'); - is($new_agent->name, 'Some New Guy', 'find_or_create on prefetched has_many with same column names: can be disambiguated with "me." for new entry'); + ok(! $new_cd->is_changed, 'find_or_create on prefetched has_many with same column names: row is clean'); + is($new_cd->title, 'Some New Guy', 'find_or_create on prefetched has_many with same column names: can be disambiguated with "me." for new entry'); } diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index e691999..a050862 100755 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -104,21 +104,11 @@ sub populate_schema { my $self = shift; my $schema = shift; - $schema->populate('Label', [ - [ qw/labelid name/ ], - [ 1, 'Acme Records' ], - ]); - - $schema->populate('Agent', [ - [ qw/agentid label name/ ], - [ 1, 1, 'Ted' ], - ]); - $schema->populate('Artist', [ - [ qw/artistid agent name/ ], - [ 1, 1, 'Caterwauler McCrae' ], - [ 2, 1, 'Random Boy Band' ], - [ 3, 1, 'We Are Goth' ], + [ qw/artistid name/ ], + [ 1, 'Caterwauler McCrae' ], + [ 2, 'Random Boy Band' ], + [ 3, 'We Are Goth' ], ]); $schema->populate('CD', [ diff --git a/t/lib/DBICTest/Schema.pm b/t/lib/DBICTest/Schema.pm index f8b9816..8e7597d 100644 --- a/t/lib/DBICTest/Schema.pm +++ b/t/lib/DBICTest/Schema.pm @@ -6,11 +6,9 @@ use base qw/DBIx::Class::Schema/; no warnings qw/qw/; __PACKAGE__->load_classes(qw/ - Agent Artist Employee CD - Label Link Bookmark #dummy diff --git a/t/lib/DBICTest/Schema/Agent.pm b/t/lib/DBICTest/Schema/Agent.pm deleted file mode 100644 index 6434393..0000000 --- a/t/lib/DBICTest/Schema/Agent.pm +++ /dev/null @@ -1,26 +0,0 @@ -package # hide from PAUSE - DBICTest::Schema::Agent; - -use base 'DBIx::Class::Core'; - -__PACKAGE__->table('agent'); -__PACKAGE__->add_columns( - 'agentid' => { - data_type => 'integer', - is_auto_increment => 1 - }, - 'label' => { - data_type => 'integer', - }, - 'name' => { - data_type => 'varchar', - size => 100, - is_nullable => 1, - }, -); -__PACKAGE__->set_primary_key('agentid'); - -__PACKAGE__->has_many( artists => 'DBICTest::Schema::Artist' ); -__PACKAGE__->belongs_to( label => 'DBICTest::Schema::Label' ); - -1; diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index 66d15b5..0bb49c4 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -9,10 +9,6 @@ __PACKAGE__->add_columns( data_type => 'integer', is_auto_increment => 1 }, - 'agent' => { - data_type => 'integer', - is_nullable => 1, - }, 'name' => { data_type => 'varchar', size => 100, @@ -23,7 +19,6 @@ __PACKAGE__->set_primary_key('artistid'); __PACKAGE__->mk_classdata('field_name_for', { artistid => 'primary key', - agent => 'agent', name => 'artist name', }); @@ -32,8 +27,6 @@ __PACKAGE__->has_many( { order_by => 'year' }, ); -__PACKAGE__->belongs_to( agent => 'DBICTest::Schema::Agent' ); - __PACKAGE__->has_many( twokeys => 'DBICTest::Schema::TwoKeys' ); __PACKAGE__->has_many( onekeys => 'DBICTest::Schema::OneKey' ); diff --git a/t/lib/DBICTest/Schema/Label.pm b/t/lib/DBICTest/Schema/Label.pm deleted file mode 100644 index 2d79bf4..0000000 --- a/t/lib/DBICTest/Schema/Label.pm +++ /dev/null @@ -1,26 +0,0 @@ -package # hide from PAUSE - DBICTest::Schema::Label; - -use base 'DBIx::Class::Core'; - -__PACKAGE__->table('label'); -__PACKAGE__->add_columns( - 'labelid' => { - data_type => 'integer', - is_auto_increment => 1 - }, - 'name' => { - data_type => 'varchar', - size => 100, - is_nullable => 1, - }, -); -__PACKAGE__->set_primary_key('labelid'); - -__PACKAGE__->has_many( - agents => 'DBICTest::Schema::Agent', - undef, - { prefetch => 'artists' } -); - -1; diff --git a/t/lib/sqlite.sql b/t/lib/sqlite.sql index 5846973..228e448 100644 --- a/t/lib/sqlite.sql +++ b/t/lib/sqlite.sql @@ -1,6 +1,6 @@ -- -- Created by SQL::Translator::Producer::SQLite --- Created on Fri Aug 4 19:03:21 2006 +-- Created on Tue Aug 8 01:53:20 2006 -- BEGIN TRANSACTION; @@ -44,15 +44,6 @@ CREATE TABLE cd_to_producer ( -- CREATE TABLE artist ( artistid INTEGER PRIMARY KEY NOT NULL, - agent integer, - name varchar(100) -); - --- --- Table: label --- -CREATE TABLE label ( - labelid INTEGER PRIMARY KEY NOT NULL, name varchar(100) ); @@ -128,24 +119,6 @@ CREATE TABLE self_ref ( ); -- --- Table: tags --- -CREATE TABLE tags ( - tagid INTEGER PRIMARY KEY NOT NULL, - cd integer NOT NULL, - tag varchar(100) NOT NULL -); - --- --- Table: agent --- -CREATE TABLE agent ( - agentid INTEGER PRIMARY KEY NOT NULL, - label integer NOT NULL, - name varchar(100) -); - --- -- Table: link -- CREATE TABLE link ( @@ -155,6 +128,15 @@ CREATE TABLE link ( ); -- +-- Table: tags +-- +CREATE TABLE tags ( + tagid INTEGER PRIMARY KEY NOT NULL, + cd integer NOT NULL, + tag varchar(100) NOT NULL +); + +-- -- Table: treelike -- CREATE TABLE treelike (