don't remove the where clause unless we're doing distinct, it needs to be there
[dbsrgits/DBIx-Class.git] / t / count_distinct.t
1 use strict;
2 use warnings;  
3
4 use Test::More;
5
6 use lib qw(t/lib);
7
8 use DBICTest;
9 use DBIC::SqlMakerTest;
10
11 my $schema = DBICTest->init_schema();
12
13 eval "use DBD::SQLite";
14 plan skip_all => 'needs DBD::SQLite for testing' if $@;
15 plan tests => 5;
16
17 cmp_ok($schema->resultset("Tag")->count({ tag => 'Blue' }),
18            '==', 9, 'Count without DISTINCT ok');
19
20 cmp_ok($schema->resultset("Tag")->count({ tag => [ 'Blue', 'Shiny' ] }, { group_by => 'tag' }),
21            '==', 2, 'Count with single column group_by ok');
22
23 cmp_ok($schema->resultset("Tag")->count({ tag => 'Blue' }, { group_by => [ qw/tag cd/ ]}), 
24            '==', 4, 'Count with multiple column group_by ok');
25
26 cmp_ok($schema->resultset("Tag")->count({ tag => 'Blue' }, { distinct => 1 }),
27            '==', 4, "Count with single column distinct ok");