#31535: Calling annotate with a case statement that references a recursive many
to
many relationship creates duplicates.
-------------------------------------+-------------------------------------
Reporter: David Cooke | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
The ORM is able to optimize `.filter(unlocked_by__in=solved_challenges)`
into an `INNER JOIN` but it cannot do the same for annotations because it
could be doing some special handling of `NULL` and it would require some
pretty sophisticated introspection to determine it's safe to do. It would
also be backward incompatible at this point. You should rely on `Subquery`
or even `Exists` in your reported case instead.
--
Ticket URL: <https://code.djangoproject.com/ticket/31535#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/069.7f25406fa4986d3f5642d985032b046a%40djangoproject.com.