From: Andy Grundman Date: Mon, 10 Aug 2009 22:34:13 +0000 (+0000) Subject: Add failing test for RT 47779, group_by as a scalar ref X-Git-Tag: v0.08109~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ffad45f5efe8cb57c77397c4676335570e00e8cf;p=dbsrgits%2FDBIx-Class.git Add failing test for RT 47779, group_by as a scalar ref --- diff --git a/t/prefetch/grouped.t b/t/prefetch/grouped.t index bd50a9d..1811069 100644 --- a/t/prefetch/grouped.t +++ b/t/prefetch/grouped.t @@ -235,4 +235,40 @@ for ($cd_rs->all) { 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;