[Bast-commits] r8835 - DBIx-Class/0.08/branches/prefetch/t/prefetch
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Mon Mar 1 00:13:51 GMT 2010
Author: ribasushi
Date: 2010-03-01 00:13:51 +0000 (Mon, 01 Mar 2010)
New Revision: 8835
Modified:
DBIx-Class/0.08/branches/prefetch/t/prefetch/incomplete.t
Log:
Sketches of test that should ultimately pass
Modified: DBIx-Class/0.08/branches/prefetch/t/prefetch/incomplete.t
===================================================================
--- DBIx-Class/0.08/branches/prefetch/t/prefetch/incomplete.t 2010-02-28 21:07:59 UTC (rev 8834)
+++ DBIx-Class/0.08/branches/prefetch/t/prefetch/incomplete.t 2010-03-01 00:13:51 UTC (rev 8835)
@@ -23,7 +23,7 @@
prefetch => [ qw/ cds / ],
order_by => [ { -desc => 'me.name' }, 'cds.title' ],
select => [qw/ me.name cds.title / ],
- }
+ },
);
is ($rs->count, 2, 'Correct number of collapsed artists');
@@ -34,6 +34,57 @@
}, 'explicit prefetch on a keyless object works');
+lives_ok ( sub {
+
+ my $rs = $schema->resultset('CD')->search(
+ {},
+ {
+ order_by => [ { -desc => 'me.year' } ],
+ }
+ );
+ my $years = [qw/ 2001 2001 1999 1998 1997/];
+
+ is_deeply (
+ [ $rs->search->get_column('me.year')->all ],
+ $years,
+ 'Expected years (at least one duplicate)',
+ );
+
+ my @cds_and_tracks;
+ for my $cd ($rs->all) {
+ my $data->{year} = $cd->year;
+ for my $tr ($cd->tracks->all) {
+ push @{$data->{tracks}}, { $tr->get_columns };
+ }
+ push @cds_and_tracks, $data;
+ }
+
+ my $pref_rs = $rs->search ({}, { columns => ['year'], prefetch => 'tracks' });
+
+ my @pref_cds_and_tracks;
+ for my $cd ($pref_rs->all) {
+ my $data = { $cd->get_columns };
+ for my $tr ($cd->tracks->all) {
+ push @{$data->{tracks}}, { $tr->get_columns };
+ }
+ push @pref_cds_and_tracks, $data;
+ }
+
+ is_deeply (
+ \@pref_cds_and_tracks,
+ \@cds_and_tracks,
+ 'Correct collapsing on non-unique primary object'
+ );
+
+ is_deeply (
+ [ $pref_rs->search ({}, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' })->all ],
+ \@cds_and_tracks,
+ 'Correct HRI collapsing on non-unique primary object'
+ );
+
+}, 'weird collapse lives');
+
+
lives_ok(sub {
# test implicit prefetch as well
More information about the Bast-commits
mailing list