Opened 9 years ago
Last modified 8 years ago
#26517 closed Bug
Empty Querset Using Empty Queryset in ExpressionWrapper — at Version 1
Reported by: | Sven R. Kunze | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
We use the ExpressionWrapper + annotate to annotate specific boolean values to all queried instances like this (minimal working example):
editable_ones = ..... # another queryset result = MyModel.objects.annotate(editable=ExpressionWrapper(Q(pk__in=editable_ones), output_field=BooleanField())
As soon as editable_ones
is empty, result
is also empty. Reading the docs, I guess this is not desired behavior (https://docs.djangoproject.com/en/1.9/ref/models/querysets/#annotate).
Note:
See TracTickets
for help on using tickets.