#27241: Annotate doesn't work with PostgreSQL views anymore
     Reporter:  jaap3                |      Owner:  nobody
         Type:  Bug                  |     Status:  new
    Component:  Database layer       |    Version:  1.10
  (models, ORM)                      |   Keywords:  postgresql view
     Severity:  Normal               |  aggregate annotate
 Triage Stage:  Unreviewed           |  Has patch:  0
Easy pickings:  0                    |      UI/UX:  0
 Using annotate on (unmanaged) models backed by views has stopped working
 and now throws a:

 `psycopg2.ProgrammingError: column "..." must appear in the GROUP BY
 clause or be used in an aggregate function...`

 This is caused by the fix to ticket #19259.

 Queries with an aggregation now only list the PK field in the `GROUP BY`
 clause, but this doesn't work for views because they cannot have primary
 keys in PostgreSQL.

 Now Django doesn't officially support views, or models without a primary
 key, but it did work before so it's somewhat of a regression.

 I ran into this problem because I'm working on a legacy database and have
 models that are backed by a view using the `db_table` Meta option.

Ticket URL: <https://code.djangoproject.com/ticket/27241>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to