9 use DBIC::SqlMakerTest;
10 use Data::Query::ExprDeclare;
12 my $schema = DBICTest->init_schema();
14 my $mccrae = $schema->resultset('Artist')
15 ->find({ name => 'Caterwauler McCrae' });
17 my @cds = $schema->resultset('CD')
18 ->search(expr { $_->artist == $mccrae->artistid });
20 is(@cds, 3, 'CDs returned from expr search by artistid');
22 my @years = $schema->resultset('CD')
23 ->search(expr { $_->year < 2000 })
27 is_deeply([ sort @years ], [ 1997, 1998, 1999 ], 'Years for < search');
29 my $tag_cond = expr { $_->tag eq 'Blue' };
31 is($schema->resultset('Tag')->search($tag_cond)->count, 4, 'Simple tag cond');
33 $tag_cond &= expr { $_->cd < 4 };
35 is($schema->resultset('Tag')->search($tag_cond)->count, 3, 'Combi tag cond');