support expr {} in join cond
[dbsrgits/DBIx-Class.git] / t / dq / join.t
CommitLineData
9f9a7365 1use strict;
2use warnings;
3
4use Test::More;
5use Test::Exception;
6use Test::Warn;
7use lib qw(t/lib);
8use DBICTest::Schema::Artist;
9use Data::Query::ExprDeclare;
10BEGIN {
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}
23use DBICTest;
24use DBIC::SqlMakerTest;
25
26my $schema = DBICTest->init_schema();
27
28my $mccrae = $schema->resultset('Artist')
29 ->find({ name => 'Caterwauler McCrae' });
30
31is($mccrae->cds2->count, 3, 'CDs returned from expr join');
32
33is($mccrae->cds2_pre2k->count, 2, 'CDs returned from expr w/cond');
34
35done_testing;