move join inference cleverness into a role
[dbsrgits/DBIx-Class.git] / t / dq / where.t
CommitLineData
8a3a5bc5 1use strict;
2use warnings;
3
4use Test::More;
5use Test::Exception;
6use Test::Warn;
7use lib qw(t/lib);
8use DBICTest;
9use DBIC::SqlMakerTest;
10use Data::Query::ExprDeclare;
11
12my $schema = DBICTest->init_schema();
13
14my $mccrae = $schema->resultset('Artist')
15 ->find({ name => 'Caterwauler McCrae' });
16
17my @cds = $schema->resultset('CD')
18 ->search(expr { $_->artist == $mccrae->artistid });
19
20is(@cds, 3, 'CDs returned from expr search by artistid');
21
22my @years = $schema->resultset('CD')
23 ->search(expr { $_->year < 2000 })
24 ->get_column('year')
25 ->all;
26
27is_deeply([ sort @years ], [ 1997, 1998, 1999 ], 'Years for < search');
28
29my $tag_cond = expr { $_->tag eq 'Blue' };
30
31is($schema->resultset('Tag')->search($tag_cond)->count, 4, 'Simple tag cond');
32
33$tag_cond &= expr { $_->cd < 4 };
34
35is($schema->resultset('Tag')->search($tag_cond)->count, 3, 'Combi tag cond');
36
37done_testing;