#34176: Annotation's original field-name can clash with result field name over
aggregation
-------------------------------------+-------------------------------------
     Reporter:  Shai Berger          |                    Owner:  Simon
                                     |  Charette
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * has_patch:  0 => 1


Comment:

 I didn't know that

 {{{#!python
 Book.objects.values('isbn').annotate(
     name=F('publisher__name'),
 )
 }}}

 was allowed but


 {{{#!python
 > Book.objects.values('isbn', name=F('publisher__name'))
 ValueError: The annotation 'name' conflicts with a field on the model.
 }}}

 isn't which seems like a bug in #25871?

 Anyway, I submitted [https://github.com/django/django/pull/16321 this MR]
 for review which avoids a complex refactor of `get_select` that would have
 necessitated reference repointing.

 This means that group by reference will be disabled for annotations that
 conflict will a selected column name but I think that's an acceptable
 compromise given it should only have an incidence for with complex
 annotations that can't be collapsed assigned with ambiguous names. This a
 compromise we already took in #31377 as well and has a workaround for
 users that must get the group be reference; use an annotation name that
 doesn't conflict with an already selected column name.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34176#comment:3>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184a206413b-66e45b78-690e-498d-8ae6-61d5acb0cc64-000000%40eu-central-1.amazonses.com.

Reply via email to