[Bast-commits] r6360 -
DBIx-Class/0.08/branches/unresolvable_prefetch/t/prefetch
arcanez at dev.catalyst.perl.org
arcanez at dev.catalyst.perl.org
Thu May 21 18:32:46 GMT 2009
Author: arcanez
Date: 2009-05-21 18:32:46 +0000 (Thu, 21 May 2009)
New Revision: 6360
Added:
DBIx-Class/0.08/branches/unresolvable_prefetch/t/prefetch/unresolvable.t
Log:
failing test
Added: DBIx-Class/0.08/branches/unresolvable_prefetch/t/prefetch/unresolvable.t
===================================================================
--- DBIx-Class/0.08/branches/unresolvable_prefetch/t/prefetch/unresolvable.t (rev 0)
+++ DBIx-Class/0.08/branches/unresolvable_prefetch/t/prefetch/unresolvable.t 2009-05-21 18:32:46 UTC (rev 6360)
@@ -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');
More information about the Bast-commits
mailing list