9 my $schema = DBICTest->init_schema(no_populate => 1);
11 $schema->resultset('CD')->create({
14 artist => { name => 'JMJ' },
15 genre => { name => 'electro' },
30 title => 'Magnetic Fields',
32 genre => { name => 'electro' },
43 { title => 'o2', position => 2}, # the position should not be here, bug in MC
49 my $rs = $schema->resultset ('CD')->search ({}, {
50 join => [ 'tracks', { single_track => { cd => { artist => { cds => 'tracks' } } } } ],
53 { 'year' => 'me.year' }, # non-unique
54 { 'genreid' => 'me.genreid' }, # nullable
55 { 'tracks.title' => 'tracks.title' }, # non-unique (no me.id)
56 { 'single_track.cd.artist.cds.cdid' => 'cds.cdid' }, # to give uniquiness to ...tracks.title below
57 { 'single_track.cd.artist.artistid' => 'artist.artistid' }, # uniqufies entire parental chain
58 { 'single_track.cd.artist.cds.year' => 'cds.year' }, # non-unique
59 { 'single_track.cd.artist.cds.genreid' => 'cds.genreid' }, # nullable
60 { 'single_track.cd.artist.cds.tracks.title' => 'tracks_2.title' }, # unique when combined with ...cds.cdid above
61 { 'latest_cd' => \ "(SELECT MAX(year) FROM cd)" }, # random function
62 { 'title' => 'me.title' }, # uniquiness for me
63 { 'artist' => 'me.artist' }, # uniquiness for me
65 order_by => [{ -desc => 'cds.year' }, { -desc => 'me.title'} ],
68 my $hri_rs = $rs->search({}, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' });
152 single_track => undef,
168 single_track => undef,
169 title => "Magnetic Fields",
187 'W00T, manual prefetch with collapse works'
193 local $TODO = 'Something is wrong with filter type rels, they throw on incomplete objects >.<';
197 { $row->single_track->get_columns },
199 'empty intermediate object ok',
204 is ($rs->cursor->next, undef, 'cursor exhausted');
207 local $TODO = 'this does not work at all, need to promote rsattrs to an object on its own';
208 # make sure has_many column redirection does not do weird stuff when collapse is requested
210 { prefetch => 'cds'},
213 for my $col_and_join_args (
214 { '+columns' => { 'cd_title' => 'cds_2.title' }, join => [ 'cds', 'cds' ] },
215 { '+columns' => { 'cd_title' => 'cds.title' }, join => 'cds', }
218 my $weird_rs = $schema->resultset('Artist')->search({}, {
219 %$col_and_join_args, %$pref_args,
222 for (qw/next all first/) {
223 throws_ok { $weird_rs->$_ } qr/not yet determined exception text/;