Failing test for prefetch bug: M -> 1 -> M with prefetch on 3rd rs, with order_by...
[dbsrgits/DBIx-Class.git] / t / prefetch / related_resultset_order_by_plus_limit.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Exception;
6 use lib qw(t/lib);
7 use DBICTest;
8
9 plan tests => 3;
10
11 my $schema = DBICTest->init_schema();
12
13
14 my $no_prefetch = $schema->resultset('Track')->search_related(cd =>
15   {
16     'cd.year' => "2000",
17   },
18   {
19     join => 'tags',
20     order_by => 'me.trackid',
21     rows => 1,
22   }
23 );
24
25 my $use_prefetch = $no_prefetch->search(
26   {},
27   {
28     prefetch => 'tags',
29   }
30 );
31
32 lives_ok {
33   $use_prefetch->all;
34 } "M -> 1 -> M with order_by using first rs and limit generates valid SQL";
35
36 is($no_prefetch->count, $use_prefetch->count, '$no_prefetch->count == $use_prefetch->count');
37 is(
38   scalar ($no_prefetch->all),
39   scalar ($use_prefetch->all),
40   "Amount of returned rows is right"
41 );