﻿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
28731	Passing an empty Q() to a When inside a Case causes an OperationError	Tom van Bussel	nobody	"The following code causes an OperationError:
{{{
q = Q() # Dynamically constructed, possibly empty
x = TestModel.objects.annotate(test_name=When(q, then=Value(True)), default=Value(False), output_field=BooleanField())).all()
print(x)
}}}
The code above results in a SQL query which contains {{{CASE WHEN  THEN}}}, with nothing between the WHEN and THEN.
"	Bug	new	Database layer (models, ORM)	1.11	Normal				Unreviewed	0	0	0	0	0	0
