Commit | Line | Data |
9f9a7365 |
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 | |
44243306 |
35 | my $cds = $schema->resultset('CD') |
36 | ->search(expr { $_->artist->name eq 'Caterwauler McCrae' }); |
37 | |
38 | is($cds->count, 3, 'CDs via join injection'); |
39 | |
40 | my $tags = $schema->resultset('Tag') |
41 | ->search(expr { $_->cd->artist->name eq 'Caterwauler McCrae' }); |
42 | |
43 | is($tags->count, 5, 'Tags via two step join injection'); |
44 | |
9f9a7365 |
45 | done_testing; |