support expr {} in join cond
[dbsrgits/DBIx-Class.git] / t / dq / join.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Exception;
6 use Test::Warn;
7 use lib qw(t/lib);
8 use DBICTest::Schema::Artist;
9 use Data::Query::ExprDeclare;
10 BEGIN {
11   DBICTest::Schema::Artist->has_many(
12     cds2 => 'DBICTest::Schema::CD',
13     expr { $_->foreign->artist == $_->self->artistid }
14   );
15   DBICTest::Schema::Artist->has_many(
16     cds2_pre2k => 'DBICTest::Schema::CD',
17     expr {
18       $_->foreign->artist == $_->self->artistid
19       & $_->foreign->year < 2000
20     }
21   );
22 }
23 use DBICTest;
24 use DBIC::SqlMakerTest;
25
26 my $schema = DBICTest->init_schema();
27
28 my $mccrae = $schema->resultset('Artist')
29                     ->find({ name => 'Caterwauler McCrae' });
30
31 is($mccrae->cds2->count, 3, 'CDs returned from expr join');
32
33 is($mccrae->cds2_pre2k->count, 2, 'CDs returned from expr w/cond');
34
35 done_testing;