[Bast-commits] r7295 - DBIx-Class/0.08/trunk/t/prefetch

andyg at dev.catalyst.perl.org andyg at dev.catalyst.perl.org
Mon Aug 10 22:34:16 GMT 2009


Author: andyg
Date: 2009-08-10 22:34:13 +0000 (Mon, 10 Aug 2009)
New Revision: 7295

Modified:
   DBIx-Class/0.08/trunk/t/prefetch/grouped.t
Log:
Add failing test for RT 47779, group_by as a scalar ref

Modified: DBIx-Class/0.08/trunk/t/prefetch/grouped.t
===================================================================
--- DBIx-Class/0.08/trunk/t/prefetch/grouped.t	2009-08-10 20:40:33 UTC (rev 7294)
+++ DBIx-Class/0.08/trunk/t/prefetch/grouped.t	2009-08-10 22:34:13 UTC (rev 7295)
@@ -235,4 +235,40 @@
   is ($rs->count, 5, 'Correct count of CDs');
 }
 
+# RT 47779, test group_by as a scalar ref
+{
+  my $track_rs = $schema->resultset ('Track')->search (
+    { 'me.cd' => { -in => [ $cd_rs->get_column ('cdid')->all ] } },
+    {
+      select => [
+        'me.cd',
+        { count => 'me.trackid' },
+      ],
+      as => [qw/
+        cd
+        track_count
+      /],
+      group_by => \'SUBSTR(me.cd, 1, 1)',
+      prefetch => 'cd',
+    },
+  );
+
+  is_same_sql_bind (
+    $track_rs->count_rs->as_query,
+    '(
+      SELECT COUNT( * )
+        FROM (
+          SELECT me.cd
+            FROM track me
+            JOIN cd cd ON cd.cdid = me.cd
+          WHERE ( me.cd IN ( ?, ?, ?, ?, ? ) )
+          GROUP BY SUBSTR(me.cd, 1, 1)
+        )
+      count_subq
+    )',
+    [ map { [ 'me.cd' => $_] } ($cd_rs->get_column ('cdid')->all) ],
+    'count() query generated expected SQL',
+  );
+}
+
 done_testing;




More information about the Bast-commits mailing list