#24752 closed Bug (fixed)
Reusing a Case/Where object in a query causes a crash
Reported by: | Suriya Subramanian | Owned by: | Anssi Kääriäinen |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Reusing a conditional expression Case / When
that has already been used causes a crash. Here is a simple example:
import django django.setup() from django.contrib.auth.models import User from django.db.models import When, Case, CharField, Value SOME_CASE = Case( When(pk=0, then=Value('0')), default=Value('1'), output_field=CharField(), ) print User.objects.annotate(somecase=SOME_CASE) print User.objects.annotate(somecase=SOME_CASE)
You can safely execute this program in your environment. The second queryset crashes because it reuses the SOME_CASE
object.
This probably related to #24420. This problem exists in both 1.8 and 1.8.1.
Change History (4)
comment:1 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
Shameless self-review.