Selection::count() ignores HAVING clausule

Notice: This thread is very old.
nanuqcz
Member | 822
+
0
-

Hello,

// Code
$conn->table('article')->group('article.id', 'id > 5')

// Generates
SELECT `id`
FROM `article`
GROUP BY `article`.`id`
HAVING `id` > 5

but

// Code
$conn->table('article')->group('article.id', 'id > 5')->count('*')

// Generates
SELECT COUNT(*)
FROM `article`

“HAVING” clausule disappear. Expected result:

SELECT COUNT(*)
FROM (
    SELECT `id`
    FROM `article`
    GROUP BY `article`.`id`
    HAVING `id` > 5
) counted_table

Thanks.

EDIT: Tested in Nette 2.0.13

Last edited by nanuqcz (2013-11-25 22:44)