#35459: Case.extra is undocumented, untested, and can hide potential issues
-------------------------------------+-------------------------------------
     Reporter:  Baptiste Mispelon    |                    Owner:  Priyank
         Type:                       |  Panchal
  Cleanup/optimization               |                   Status:  assigned
    Component:  Database layer       |                  Version:  5.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Tim Graham):

 The proposed test doesn't seem to be a compelling use case:
 {{{#!python
 Subquery(
     Employee.objects.all().values("salary"),
     salary=20,
     template="(SELECT salary FROM (%(subquery)s) _subquery "
     "WHERE salary = %(salary)s)",
 )
 }}}
 If the programmer provides a custom template, it seems they can just as
 easily interpolate parameters into that template beforehand without
 relying on `Subquery` to do it.

 I'm not sure if it was correct to include `**extra` in the original patch
 for `Case` considering it was undocumented and untested.

 Sarah's comment 1 references #25759 but that's about adding
 `**extra_context` to `as_sql()`, not `**extra` in `__init__()`. While
 `Func.__init__()` accepts `**extra`, its subclasses do so inconsistently
 (and when it does, the use case seems to be setting `output_field`).
 Further,  `Case` and `Subquery` inherit from `BaseExpression` (which
 doesn't accept `**extra`), not from `Func`.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35459#comment:13>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070191c2546a2d-20ba1eee-9ab7-4547-b9b4-1931d83e8709-000000%40eu-central-1.amazonses.com.

Reply via email to