﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25507	count() crashes with a RawSQL annotation.	Antoine Catton	nobody	"The simplest test case for this is:

{{{
>>> User.objects.annotate(foo=RawSQL('%s', ['value', ])).count()
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File "".../django/db/models/query.py"", line 371, in count
    return self.query.get_count(using=self.db)
  File "".../django/db/models/sql/query.py"", line 483, in get_count
    q = self.clone()
  File "".../django/db/models/sql/query.py"", line 464, in get_aggregation
    for (alias, annotation), val
  File "".../django/db/models/sql/compiler.py"", line 852, in execute_sql
    return val[0:self.col_count]
  File "".../django/db/backends/utils.py"", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "".../django/db/backends/utils.py"", line 64, in execute
    return self.cursor.execute(sql, params)
  File "".../django/db/utils.py"", line 95, in __exit__
    # Note that we are intentionally not using @wraps here for performance
  File "".../django/utils/six.py"", line 658, in reraise
    raise value.with_traceback(tb)
  File "".../django/db/backends/utils.py"", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: non-integer constant in GROUP BY
LINE 1: ...M ""accounts_user"" GROUP BY ""accounts_user"".""id"", ('value')) ...
                                                             ^
}}}

This error only happens when using PostgreSQL."	Bug	closed	Database layer (models, ORM)	dev	Normal	fixed	RawSQL filter ORM sql	Can Sarıgöl	Accepted	0	0	0	0	0	0
