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