13 views
Skip to first unread message

Aaron C. de Bruyn

unread,
Feb 29, 2016, 3:56:07 PM2/29/16
to django...@googlegroups.com
A simple annotation broke when I migrated by app from Django 1.8.x to 1.9.2, and I can't figure out why for the life of me.

Calling Company.objects.all().annotate(ticketcount=Count('srservice'))

throws an error "ProgrammingError: column "company.owner_id" must appear in the GROUP BY clause or be used in an aggregate function"

Rolling back to Django 1.8.5 fixes the problem.
The DB backend is Postgres.

Please ignore the horrible DB schema.  It's not mine.  It's an introspection of a horrible Windows ticketing app.


Am I missing something?

-A

Simon Charette

unread,
Feb 29, 2016, 6:06:06 PM2/29/16
to Django users
Hi Aaron,

I think this could be related to the version of your PostgreSQL server.

Django 1.9 dropped support for PostgreSQL 9.0[1] which doesn't support
GROUP BY selected primary keys[2].

Cheers,
Simon

[1] https://docs.djangoproject.com/en/1.9/releases/1.9/#dropped-support-for-postgresql-9-0
[2] https://github.com/django/django/commit/dc27f3ee0c3eb9bb17d6cb764788eeaf73a371d7
Reply all
Reply to author
Forward
0 new messages