#24752: Reusing a Case/Where object in a query causes a crash
----------------------------------------------+--------------------
     Reporter:  mssnlayam                     |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.8
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24752>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.0a4f5ddc5db2e90d2fb04051fc4743a4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to