#25507: Can't count when using annotate(field=RawSQL(...))
-------------------------------+--------------------
Reporter: acatton | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/25507>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.1ed436402b40388cfb20107d0302705a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.