#25260: Sets in "in" lookups should be converted to list if backend doesn't
support
sets
----------------------------------------------+--------------------
Reporter: Naddiseo | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer (models, ORM) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
Consider the following:
{{{#!python
Model.objects.filter(pk__in = set([1, 1, 2, 3, 4, 3]))
}}}
If the backend is mysql, the generated SQL will contain `WHERE id IN (1,
2, 3, 4)`. If the backend is postgresql there is an error: "can't adapt
type 'set'".
Argument: switching between backends should not throw an error from the
backend if the plain ORM (no backend-specific elements) is used.
I'm not sure where this belongs, but django shouldn't be throwing a
backend error for this case.
Some potential fixes:
- Call `list()` on any iterable that's used for `__in` filters.
(Preferable for me, should be non-breaking except in edge-cases)
- Disallow `set`s for all backends. (Enforces the same behaviour across
all backends, but backward incompatible)
- Add adapter for sets to postgresql backend. (Might cause strange
behaviour in cases where the set is used for other contexts)
--
Ticket URL: <https://code.djangoproject.com/ticket/25260>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.cbbdec262d095a7286adafcb99a95f10%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.