#25759: Add **kwargs to as_sql method of Expressions
-------------------------------------+-------------------------------------
               Reporter:  jarshwah   |          Owner:  nobody
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Database   |        Version:  master
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  expressions
           Triage Stage:  Accepted   |      Has patch:  0
    Needs documentation:  1          |    Needs tests:  1
Patch needs improvement:  1          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 A common pattern when overriding `as_sql` or implementing `as_vendor` with
 expressions is to modify the template or function attributes before
 rendering the expression. This isn't safe to do, because expressions can
 be shared between backends.

 It'd be a good idea to add `**kwargs` to the method signature, so that
 overrides can add context to that specific method call without mutating
 the expression itself. For expressions like `Func`, it could mix the
 `kwargs` with `self.extra` during rendering. Unsure how `**kwargs` would
 affect other expression types, but that can be opt in per type.

 Once this is done, the documentation written for
 https://github.com/django/django/pull/5574 for third party backend
 overrides will need to be updated to take advantage of the new `kwargs`.

--
Ticket URL: <https://code.djangoproject.com/ticket/25759>
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/051.51dd672553552d3ec93043ec97214751%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to