﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24752	Reusing a Case/Where object in a query causes a crash	Suriya Subramanian	Anssi Kääriäinen	"Reusing a conditional expression `Case / When` that has already been used causes a crash. Here is a simple example:

{{{#!python
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."	Bug	closed	Database layer (models, ORM)	1.8	Normal	fixed			Ready for checkin	0	0	0	0	0	0
