From: Justin Hunter Date: Thu, 21 May 2009 18:32:46 +0000 (+0000) Subject: failing test X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5aa25b935d76cace59fe42901a04c7aee87d0731;p=dbsrgits%2FDBIx-Class-Historic.git failing test --- diff --git a/t/prefetch/unresolvable.t b/t/prefetch/unresolvable.t new file mode 100644 index 0000000..9ec283a --- /dev/null +++ b/t/prefetch/unresolvable.t @@ -0,0 +1,51 @@ +use strict; +use warnings; + +use Test::More; +use Test::Exception; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest->init_schema(); + +eval "use DBD::SQLite"; +plan skip_all => 'needs DBD::SQLite for testing' if $@; +plan tests => 1; + +=cut +test fails with select => [ ], when the columns required for the relationship are absent + +DBIC_TRACE=1: + + with select => [ qw / me.name cds.title ] (missing columns required for relationships) + + SELECT me.name, cds.title, cds.cdid, cds.artist, cds.title, cds.year, cds.genreid, cds.single_track + FROM artist me + LEFT JOIN cd cds ON cds.artist = me.artistid + WHERE ( cds.title != ? ) + GROUP BY me.name, cds.title + ORDER BY me.name, cds.title, cds.artist, cds.year: 'Generic Manufactured Singles' + + **************************************************************************************************************************** + + with no select => [ ] + + SELECT me.artistid, me.name, me.rank, me.charfield, cds.cdid, cds.artist, cds.title, cds.year, cds.genreid, cds.single_track + FROM artist me + LEFT JOIN cd cds ON cds.artist = me.artistid + WHERE ( cds.title != ? ) + GROUP BY me.artistid, me.name, me.rank, me.charfield + ORDER BY me.name, cds.title, cds.artist, cds.year: 'Generic Manufactured Singles' + +=cut + + +my $rs = $schema->resultset('Artist')->search({ 'cds.title' => { '!=' => 'Generic Manufactured Singles' } }, ## exists + { prefetch => [ qw/ cds / ], + join => [ qw/ cds / ], + select => [ qw/ me.name cds.title / ], + distinct => 1, + order_by => [ qw/ me.name cds.title / ], + }); + +lives_ok(sub { $rs->first }, 'Lives ok');