#34728: OR operator on queryset does not work as expected
-------------------------------------+-------------------------------------
Reporter: Inglorious-Inge | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: queryset OR | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by René Fleschenberg):
As you can see on the main branch of the repository linked above by the
reporter, the query works as expected if it is rewritten to use {{{Q}}}
objects:
{{{#!python
return Recipe.objects.annotate(
shared_ingredients=Count("ingredients")
).filter(has_shared_ingredients).filter(
Q(same_tag, shared_ingredients__gte=2)
| Q(shared_ingredients__gte=4)
).exclude(id=self.id)
}}}
Thanks to CodenameTim on the Django Discord for helping to debug this!
--
Ticket URL: <https://code.djangoproject.com/ticket/34728#comment:1>
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/0107018974cf69a3-16f338c0-cfa6-43c2-8521-8ca435200d50-000000%40eu-central-1.amazonses.com.