Commit | Line | Data |
c0329273 |
1 | BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } |
2 | |
574dd7c9 |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
c0329273 |
7 | |
574dd7c9 |
8 | use DBICTest; |
9 | |
10 | my $schema = DBICTest->init_schema(); |
11 | |
12 | my $cds_rs = $schema->resultset('CD')->search( |
13 | [ |
14 | { |
15 | 'me.title' => "Caterwaulin' Blues", |
16 | 'cds.title' => { '!=' => 'Forkful of bees' } |
17 | }, |
18 | { |
19 | 'me.title' => { '!=', => "Caterwaulin' Blues" }, |
20 | 'cds.title' => 'Forkful of bees' |
21 | }, |
22 | ], |
23 | { |
fb88ca2c |
24 | order_by => [qw(me.cdid cds.title)], |
574dd7c9 |
25 | prefetch => { artist => 'cds' }, |
26 | result_class => 'DBIx::Class::ResultClass::HashRefInflator', |
27 | }, |
28 | ); |
29 | |
30 | is_deeply [ $cds_rs->all ], [ |
31 | { |
32 | 'single_track' => undef, |
33 | 'cdid' => '1', |
34 | 'artist' => { |
35 | 'cds' => [ |
36 | { |
37 | 'single_track' => undef, |
38 | 'artist' => '1', |
39 | 'cdid' => '2', |
40 | 'title' => 'Forkful of bees', |
41 | 'genreid' => undef, |
42 | 'year' => '2001' |
43 | }, |
44 | ], |
45 | 'artistid' => '1', |
46 | 'charfield' => undef, |
47 | 'name' => 'Caterwauler McCrae', |
48 | 'rank' => '13' |
49 | }, |
50 | 'title' => 'Spoonful of bees', |
51 | 'year' => '1999', |
52 | 'genreid' => '1' |
53 | }, |
54 | { |
55 | 'single_track' => undef, |
56 | 'cdid' => '2', |
57 | 'artist' => { |
58 | 'cds' => [ |
59 | { |
60 | 'single_track' => undef, |
61 | 'artist' => '1', |
62 | 'cdid' => '2', |
63 | 'title' => 'Forkful of bees', |
64 | 'genreid' => undef, |
65 | 'year' => '2001' |
66 | }, |
67 | ], |
68 | 'artistid' => '1', |
69 | 'charfield' => undef, |
70 | 'name' => 'Caterwauler McCrae', |
71 | 'rank' => '13' |
72 | }, |
73 | 'title' => 'Forkful of bees', |
74 | 'year' => '2001', |
75 | 'genreid' => undef |
76 | }, |
77 | { |
78 | 'single_track' => undef, |
79 | 'cdid' => '3', |
80 | 'artist' => { |
81 | 'cds' => [ |
82 | { |
83 | 'single_track' => undef, |
84 | 'artist' => '1', |
85 | 'cdid' => '3', |
86 | 'title' => 'Caterwaulin\' Blues', |
87 | 'genreid' => undef, |
88 | 'year' => '1997' |
89 | }, |
90 | { |
91 | 'single_track' => undef, |
92 | 'artist' => '1', |
93 | 'cdid' => '1', |
94 | 'title' => 'Spoonful of bees', |
95 | 'genreid' => '1', |
96 | 'year' => '1999' |
97 | } |
98 | ], |
99 | 'artistid' => '1', |
100 | 'charfield' => undef, |
101 | 'name' => 'Caterwauler McCrae', |
102 | 'rank' => '13' |
103 | }, |
104 | 'title' => 'Caterwaulin\' Blues', |
105 | 'year' => '1997', |
106 | 'genreid' => undef |
107 | } |
108 | ], 'multi-level prefetch with restrictions ok'; |
109 | |
110 | done_testing; |