1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
11 # More tests like this in t/prefetch/manual.t
13 my $schema = DBICTest->init_schema(no_populate => 1, quote_names => 1);
14 $schema->resultset('Artist')->create({ name => 'JMJ', cds => [{
15 title => 'Magnetic Fields',
17 genre => { name => 'electro' },
27 $schema->resultset('CD')->create({
30 artist => { name => 'JMJ' },
31 genre => { name => 'electro' },
42 artist => { name => 'JMJ' },
45 { title => 'o2', position => 2}, # the position should not be needed here, bug in MC
52 $schema->resultset('CD')->create({ artist => 1, year => 1977, title => "fuzzy_$_" });
56 package DBICTest::HRI::Subclass;
57 use base 'DBIx::Class::ResultClass::HashRefInflator';
61 package DBICTest::HRI::Around;
62 use base 'DBIx::Class::ResultClass::HashRefInflator';
64 sub inflate_result { shift->next::method(@_) }
68 $schema->resultset('CD')->search_rs({}, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' }),
69 $schema->resultset('CD')->search_rs({}, { result_class => 'DBICTest::HRI::Subclass' }),
70 $schema->resultset('CD')->search_rs({}, { result_class => 'DBICTest::HRI::Around' }),
77 'single_track.cd.artist.name' => 'artist.name',
79 join => { single_track => { cd => 'artist' } },
80 order_by => [qw/me.cdid artist.artistid/],
83 { year => 1981, single_track => undef },
84 { year => 1976, single_track => undef },
85 { year => 1978, single_track => {
87 artist => { name => "JMJ" }
90 { year => 1977, single_track => undef },
91 { year => 1977, single_track => undef },
94 'plain 1:1 descending chain ' . $rs->result_class
100 'artist' => 'me.artist',
101 'title' => 'me.title',
103 'single_track.cd.artist.artistid' => 'artist.artistid',
104 'single_track.cd.artist.cds.cdid' => 'cds.cdid',
105 'single_track.cd.artist.cds.tracks.title' => 'tracks.title',
107 join => { single_track => { cd => { artist => { cds => 'tracks' } } } },
108 order_by => [qw/me.cdid artist.artistid cds.cdid tracks.trackid/],
112 artist => 1, title => "Magnetic Fields", year => 1981, single_track => undef,
115 artist => 1, title => "Oxygene", year => 1976, single_track => undef,
118 artist => 1, title => "Equinoxe", year => 1978, single_track => {
121 artistid => 1, cds => {
122 cdid => 1, tracks => {
131 artist => 1, title => "Equinoxe", year => 1978, single_track => {
134 artistid => 1, cds => {
135 cdid => 1, tracks => {
144 artist => 1, title => "Equinoxe", year => 1978, single_track => {
147 artistid => 1, cds => {
148 cdid => 1, tracks => {
157 artist => 1, title => "Equinoxe", year => 1978, single_track => {
160 artistid => 1, cds => {
161 cdid => 1, tracks => {
170 artist => 1, title => "Equinoxe", year => 1978, single_track => {
173 artistid => 1, cds => {
174 cdid => 2, tracks => {
183 artist => 1, title => "Equinoxe", year => 1978, single_track => {
186 artistid => 1, cds => {
187 cdid => 2, tracks => {
196 artist => 1, title => "Equinoxe", year => 1978, single_track => {
199 artistid => 1, cds => {
200 cdid => 3, tracks => {
209 artist => 1, title => "Equinoxe", year => 1978, single_track => {
212 artistid => 1, cds => {
213 cdid => 3, tracks => {
222 artist => 1, title => "Equinoxe", year => 1978, single_track => {
225 artistid => 1, cds => {
226 cdid => 3, tracks => {
235 artist => 1, title => "Equinoxe", year => 1978, single_track => {
238 artistid => 1, cds => {
239 cdid => 4, tracks => undef
246 artist => 1, title => "Equinoxe", year => 1978, single_track => {
249 artistid => 1, cds => {
250 cdid => 5, tracks => undef
257 artist => 1, title => "fuzzy_1", year => 1977, single_track => undef,
260 artist => 1, title => "fuzzy_2", year => 1977, single_track => undef,
263 'non-collapsing 1:1:1:M:M chain ' . $rs->result_class,
269 'artist' => 'me.artist',
270 'title' => 'me.title',
272 'single_track.cd.artist.artistid' => 'artist.artistid',
273 'single_track.cd.artist.cds.cdid' => 'cds.cdid',
274 'single_track.cd.artist.cds.tracks.title' => 'tracks.title',
276 join => { single_track => { cd => { artist => { cds => 'tracks' } } } },
277 order_by => [qw/me.cdid artist.artistid cds.cdid tracks.trackid/],
282 artist => 1, title => "Magnetic Fields", year => 1981, single_track => undef,
285 artist => 1, title => "Oxygene", year => 1976, single_track => undef,
288 artist => 1, title => "Equinoxe", year => 1978, single_track => {
291 artistid => 1, cds => [
293 cdid => 1, tracks => [
301 cdid => 2, tracks => [
307 cdid => 3, tracks => [
314 cdid => 4, tracks => [],
317 cdid => 5, tracks => [],
325 artist => 1, title => "fuzzy_1", year => 1977, single_track => undef,
328 artist => 1, title => "fuzzy_2", year => 1977, single_track => undef,
331 'collapsing 1:1:1:M:M chain ' . $rs->result_class,
337 'tracks.title' => 'e2',
338 'cds.title' => 'Oxygene',
344 { single_track => { cd => 'mandatory_artwork' } },
345 { artist => { cds => 'mandatory_artwork'} },
349 'single_track.cd.mandatory_artwork.cd_id' => 'mandatory_artwork.cd_id',
350 'artist.cds.mandatory_artwork.cd_id' => 'mandatory_artwork_2.cd_id',
359 mandatory_artwork => { cd_id => 2 },
364 { mandatory_artwork => { cd_id => 2 } }