#32809: Filtering with Q and OR gets duplicated entries
-------------------------------------+-------------------------------------
Reporter: Ismael | Owner: nobody
Jerez |
Type: Bug | Status: new
Component: Database | Version: 3.2
layer (models, ORM) | Keywords: queryset, Q,
Severity: Normal | filtering, OR, annotation, |
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hi:
Django version: 3.2.4
Python version: 3.8
I cannot reproduce this bug in a simple example, so I can only show you
screenshots from my Pycharm Debug Tool, I am sorry.
I have one queryset with 3 objects which contains annotations, CharField
and ManyToManyField attributes. Then I filter by a query using Q like
this:
{{{
(OR: ('created_date_dt_custom__icontains', 'a'), ('id__icontains', 'a'),
('title__unaccent__icontains', 'a'), ('created_date_dt_custom__icontains',
'a'), ('id__icontains', 'a'), ('title__unaccent__icontains', 'a'),
('promoters__in', <QuerySet [<User: admin>, <User: u********>]>))
}}}
And gets a queryset with 4 objects as a result, one of the objects is
duplicated. If I delete the last filter ('promoters__in', <QuerySet
[<User: admin>, <User: u********>]>) it works fine, so the problem is on
this filter or maybe the concatenation of filters with this kind.
I have no problem on Django version ~= 2.
Here are the screenshots of my debug tool showing the problem:
- Screenshot of the code: https://i.ibb.co/Fnb53rn/ss1.png
- Screenshot of debug tool with variable values (Project object (19)
duplicated): https://i.ibb.co/b34FwSM/ss2.png
Thank you in advance, hope it is fixed soon,
Ismael.
--
Ticket URL: <https://code.djangoproject.com/ticket/32809>
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/057.8700912b37820876c310751b26753657%40djangoproject.com.