From: Peter Rabbitson Date: Thu, 26 Nov 2009 13:23:28 +0000 (+0000) Subject: Add a no-accessor column to generally test handling X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=972015a720dac187c82c75642c733299b897b40d;p=dbsrgits%2FDBIx-Class-Historic.git Add a no-accessor column to generally test handling --- diff --git a/t/93single_accessor_object.t b/t/93single_accessor_object.t index 2303bdb..892e656 100644 --- a/t/93single_accessor_object.t +++ b/t/93single_accessor_object.t @@ -48,7 +48,7 @@ $schema = DBICTest->init_schema(); my $artist = $schema->resultset('Artist')->create({ artistid => 666, name => 'bad religion' }); my $cd = $schema->resultset('CD')->create({ cdid => 187, artist => 1, title => 'how could hell be any worse?', year => 1982, genreid => undef }); - ok(!defined($cd->genreid), 'genreid is NULL'); + ok(!defined($cd->get_column('genreid')), 'genreid is NULL'); #no accessor was defined for this column ok(!defined($cd->genre), 'genre accessor returns undef'); } diff --git a/t/count/prefetch.t b/t/count/prefetch.t index 8012e10..a0b6d75 100644 --- a/t/count/prefetch.t +++ b/t/count/prefetch.t @@ -39,16 +39,9 @@ my $schema = DBICTest->init_schema(); # collapsing prefetch with distinct { - my $first_cd = $schema->resultset('Artist')->first->cds->first; - $first_cd->update ({ - genreid => $first_cd->create_related ( - genre => ({ name => 'vague genre' }) - )->id - }); - my $rs = $schema->resultset("Artist")->search(undef, {distinct => 1}) ->search_related('cds')->search_related('genre', - { 'genre.name' => { '!=', 'foo' } }, + { 'genre.name' => 'emo' }, { prefetch => q(cds) }, ); is ($rs->all, 1, 'Correct number of objects'); @@ -64,11 +57,11 @@ my $schema = DBICTest->init_schema(); JOIN cd cds ON cds.artist = me.artistid JOIN genre genre ON genre.genreid = cds.genreid LEFT JOIN cd cds_2 ON cds_2.genreid = genre.genreid - WHERE ( genre.name != ? ) + WHERE ( genre.name = ? ) GROUP BY genre.genreid ) count_subq )', - [ [ 'genre.name' => 'foo' ] ], + [ [ 'genre.name' => 'emo' ] ], ); } diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index ee55792..852d07a 100644 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -155,6 +155,11 @@ sub populate_schema { my $self = shift; my $schema = shift; + $schema->populate('Genre', [ + [qw/genreid name/], + [qw/1 emo /], + ]); + $schema->populate('Artist', [ [ qw/artistid name/ ], [ 1, 'Caterwauler McCrae' ], @@ -163,8 +168,8 @@ sub populate_schema { ]); $schema->populate('CD', [ - [ qw/cdid artist title year/ ], - [ 1, 1, "Spoonful of bees", 1999 ], + [ qw/cdid artist title year genreid/ ], + [ 1, 1, "Spoonful of bees", 1999, 1 ], [ 2, 1, "Forkful of bees", 2001 ], [ 3, 1, "Caterwaulin' Blues", 1997 ], [ 4, 2, "Generic Manufactured Singles", 2001 ], @@ -243,7 +248,7 @@ sub populate_schema { $schema->populate('TreeLike', [ [ qw/id parent name/ ], - [ 1, undef, 'root' ], + [ 1, undef, 'root' ], [ 2, 1, 'foo' ], [ 3, 2, 'bar' ], [ 6, 2, 'blop' ], diff --git a/t/lib/DBICTest/Schema/CD.pm b/t/lib/DBICTest/Schema/CD.pm index 1463d00..a271dd8 100644 --- a/t/lib/DBICTest/Schema/CD.pm +++ b/t/lib/DBICTest/Schema/CD.pm @@ -26,6 +26,7 @@ __PACKAGE__->add_columns( 'genreid' => { data_type => 'integer', is_nullable => 1, + accessor => 'undef', }, 'single_track' => { data_type => 'integer',