-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Milestone
Description
Currently there is possibility to bind extra context parameters via keyword args of .values()
, .values_list()
, .iterator()
, .dictiterator()
and .scalar()
methods. This is quite useful, but:
- passing extra kwargs makes a hidden copy of the
TemplateQuery
object, which can't be retrieved because.values*()
methods returns aSQLResult
-like classes - while refactoring a code the mistakes are quite easy to get, when wrapping queries as a context vars for outer templates (
outer = sqltemplate.get('outer.sql).values(sql=inner.values(some_arg=1))
- please look at usage of.values()
) - the interface of
.values()
and.values_list()
are quite different from Django'sQuerySet
similar methods
Possibe solutions:
- make
.values()
similar to Django' methods by auto-wrapping original query with something likeselect {{ columns|join:"," }} from ({{ sql|safe }}) x
(beware of SQL dialects) - let the
.values()
returns a lazy result contained within a clonedTemplateQuery
object to allow embedding (as a solution for refactoring issue) - do not allow to modify context by
.values()
-like methods