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