[Bast-commits] r7853 - DBIx-Class/0.08/branches/prefetch-group_by/t/prefetch

edenc at dev.catalyst.perl.org edenc at dev.catalyst.perl.org
Tue Nov 10 19:21:39 GMT 2009


Author: edenc
Date: 2009-11-10 19:21:38 +0000 (Tue, 10 Nov 2009)
New Revision: 7853

Modified:
   DBIx-Class/0.08/branches/prefetch-group_by/t/prefetch/grouped.t
Log:
added test case for ensuring a column mentioned in the order by clause is also included in the group by clause

Modified: DBIx-Class/0.08/branches/prefetch-group_by/t/prefetch/grouped.t
===================================================================
--- DBIx-Class/0.08/branches/prefetch-group_by/t/prefetch/grouped.t	2009-11-10 19:15:15 UTC (rev 7852)
+++ DBIx-Class/0.08/branches/prefetch-group_by/t/prefetch/grouped.t	2009-11-10 19:21:38 UTC (rev 7853)
@@ -217,7 +217,7 @@
     $rs->as_query,
     '(
       SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track,
-             tags.tagid, tags.cd, tags.tag 
+             tags.tagid, tags.cd, tags.tag
         FROM (
           SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track
             FROM cd me
@@ -329,4 +329,27 @@
     );
 }
 
+{
+    my $rs = $schema->resultset('CD')->search({},
+        {
+           '+select' => [{ count => 'tags.tag' }],
+           '+as' => ['test_count'],
+           prefetch => ['tags'],
+           distinct => 1,
+           order_by => {'-asc' => 'tags.tag'},
+           rows => 1
+        }
+    );
+    is_same_sql_bind($rs->as_query, q{
+        SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track, me.test_count, tags.tagid, tags.cd, tags.tag
+        FROM (SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track, COUNT( tags.tag ) AS test_count
+                FROM cd me LEFT JOIN tags tags ON tags.cd = me.cdid
+            GROUP BY me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track, tags.tag
+            ORDER BY tags.tag ASC LIMIT 1)
+            me
+        LEFT JOIN tags tags ON tags.cd = me.cdid
+        ORDER BY tags.tag ASC, tags.cd, tags.tag
+    }, []);
+}
+
 done_testing;




More information about the Bast-commits mailing list