Fix a corner case when a distinct plus an unqualified order_by on one
[dbsrgits/DBIx-Class.git] / t / search / distinct.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Exception;
6
7 use lib qw(t/lib);
8 use DBIC::SqlMakerTest;
9 use DBICTest;
10
11 my $schema = DBICTest->init_schema();
12
13 # make sure order + distinct do not double-inject group criteria
14 my $year_rs = $schema->resultset ('CD')->search ({}, {
15   distinct => 1,
16   columns => [qw/year/],
17   order_by => 'year',
18 });
19
20 is_same_sql_bind (
21   $year_rs->as_query,
22   '(
23     SELECT me.year
24       FROM cd me
25     GROUP BY me.year
26     ORDER BY year
27   )',
28   [],
29   'Correct GROUP BY',
30 );
31
32 done_testing;