auto-add relations if they are used in the where but not in join
[dbsrgits/DBIx-Class-Historic.git] / t / distinct_count.t
CommitLineData
4c26f185 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use lib '/sporkrw/xfer/DBIx-Class/0.08/branches/count_distinct/lib';
7use DBICTest;
8
9my $schema = DBICTest->init_schema();
10
11eval "use DBD::SQLite";
12plan skip_all => 'needs DBD::SQLite for testing' if $@;
13plan tests => 4;
14
15cmp_ok($schema->resultset("Tag")->count({ tag => 'Blue' }),
16 '==', 9, 'Count without DISTINCT ok');
17
18cmp_ok($schema->resultset("Tag")->count({ tag => [ 'Blue', 'Shiny' ] }, { group_by => 'tag' }),
19 '==', 2, 'Count with single column group_by ok');
20
21cmp_ok($schema->resultset("Tag")->count({ tag => 'Blue' }, { group_by => [ qw/tag cd/ ]}),
22 '==', 4, 'Count with multiple column group_by ok');
23
24cmp_ok($schema->resultset("Tag")->count({ tag => 'Blue' }, { distinct => 1 }),
25 '==', 4, "Count with single column distinct ok");
26