From: Norbert Buchmuller Date: Fri, 24 Jul 2009 06:06:19 +0000 (+0200) Subject: Failing test for prefetch bug: M -> 1 -> M with prefetch on 3rd rs, with order_by... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=23b67299bf3b2c3979f5193475088e780909109a;p=dbsrgits%2FDBIx-Class-Historic.git Failing test for prefetch bug: M -> 1 -> M with prefetch on 3rd rs, with order_by on 1st rs and limit generates invalid SQL. --- diff --git a/t/prefetch/related_resultset_order_by_plus_limit.t b/t/prefetch/related_resultset_order_by_plus_limit.t new file mode 100644 index 0000000..e0a7a74 --- /dev/null +++ b/t/prefetch/related_resultset_order_by_plus_limit.t @@ -0,0 +1,41 @@ +use strict; +use warnings; + +use Test::More; +use Test::Exception; +use lib qw(t/lib); +use DBICTest; + +plan tests => 3; + +my $schema = DBICTest->init_schema(); + + +my $no_prefetch = $schema->resultset('Track')->search_related(cd => + { + 'cd.year' => "2000", + }, + { + join => 'tags', + order_by => 'me.trackid', + rows => 1, + } +); + +my $use_prefetch = $no_prefetch->search( + {}, + { + prefetch => 'tags', + } +); + +lives_ok { + $use_prefetch->all; +} "M -> 1 -> M with order_by using first rs and limit generates valid SQL"; + +is($no_prefetch->count, $use_prefetch->count, '$no_prefetch->count == $use_prefetch->count'); +is( + scalar ($no_prefetch->all), + scalar ($use_prefetch->all), + "Amount of returned rows is right" +);