Merge 'trunk' into 'prefetch_bug-unqualified_column_in_search_related_cond'
[dbsrgits/DBIx-Class.git] / t / 77join_count.t
CommitLineData
70350518 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
a47e1233 8my $schema = DBICTest->init_schema();
0567538f 9
10eval "use DBD::SQLite";
11plan skip_all => 'needs DBD::SQLite for testing' if $@;
12plan tests => 4;
13
f9db5527 14cmp_ok($schema->resultset("CD")->count({ 'artist.name' => 'Caterwauler McCrae' },
0567538f 15 { join => 'artist' }),
16 '==', 3, 'Count by has_a ok');
17
f9db5527 18cmp_ok($schema->resultset("CD")->count({ 'tags.tag' => 'Blue' }, { join => 'tags' }),
0567538f 19 '==', 4, 'Count by has_many ok');
20
f9db5527 21cmp_ok($schema->resultset("CD")->count(
0567538f 22 { 'liner_notes.notes' => { '!=' => undef } },
23 { join => 'liner_notes' }),
24 '==', 3, 'Count by might_have ok');
25
f9db5527 26cmp_ok($schema->resultset("CD")->count(
0567538f 27 { 'year' => { '>', 1998 }, 'tags.tag' => 'Cheesy',
28 'liner_notes.notes' => { 'like' => 'Buy%' } },
29 { join => [ qw/tags liner_notes/ ] } ),
30 '==', 2, "Mixed count ok");
31