[Bast-commits] r8718 -
DBIx-Class/0.08/branches/group_by_consistency/t
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Mon Feb 15 18:45:05 GMT 2010
Author: ribasushi
Date: 2010-02-15 18:45:05 +0000 (Mon, 15 Feb 2010)
New Revision: 8718
Modified:
DBIx-Class/0.08/branches/group_by_consistency/t/88result_set_column.t
Log:
Failing test (more to come)
Modified: DBIx-Class/0.08/branches/group_by_consistency/t/88result_set_column.t
===================================================================
--- DBIx-Class/0.08/branches/group_by_consistency/t/88result_set_column.t 2010-02-15 15:11:52 UTC (rev 8717)
+++ DBIx-Class/0.08/branches/group_by_consistency/t/88result_set_column.t 2010-02-15 18:45:05 UTC (rev 8718)
@@ -119,6 +119,41 @@
);
});
+# test exotic scenarious
+# "How many CDs have been released per year where a given CD has at least one track and the artist isn't evancarroll?"
+lives_ok ( sub {
+ my $rs = $schema->resultset ('CD')->search (
+ { 'artist.name' => { '!=', 'evancarrol' }, 'tracks.trackid' => { '!=', undef } },
+ {
+ order_by => 'me.year',
+ join => [qw/artist tracks/],
+ columns => [ { year => 'me.year'}, { cnt => { count => '*' }} ],
+ },
+ );
+
+ my $sets = {
+ grouped => $rs->search_rs ({}, { group_by => 'year' }),
+ distinct => $rs->search_rs ({}, { distinct => 1 }),
+ };
+
+ for my $type (sort keys %$sets) {
+ is ($sets->{$type}->count, 4, "correct $type amount");
+
+ is_deeply (
+ [ $sets->{$type}->get_column ('year')->all ],
+ [qw/1997 1998 1999 2001/],
+ "Get grouped column with $type works",
+ );
+
+ is_deeply (
+ [ $sets->{$type}->get_column ('cnt')->all ],
+ [qw/1 1 1 2/],
+ "Get aggregate over $type works",
+ );
+ }
+});
+
+
# test for prefetch not leaking
{
my $rs = $schema->resultset("CD")->search({}, { prefetch => 'artist' });
More information about the Bast-commits
mailing list