#31918: in_bulk not working for distinct fields
-------------------------------------+-------------------------------------
Reporter: Wolph | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 3.1
layer (models, ORM) | Keywords: in_bulk, distinct,
Severity: Normal | queryset
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
The `in_bulk` queryset function currently checks for the `pk` field or for
`unique` fields. But if you do a `queryset.distinct(field)` that field is
also unique for that queryset so it should be usable for an `in_bulk`.
I believe the fix would be as easy as patching these lines:
https://github.com/django/django/blob/41725602afebe2ddb018b99afe134384cc3bf69e/django/db/models/query.py#L699-L703
To include `and field_name not in self.query.distinct_fields`
--
Ticket URL: <https://code.djangoproject.com/ticket/31918>
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/048.81c21b51eab011c1cf6f813e6bf2e714%40djangoproject.com.