1
0
mirror of https://github.com/django/django.git synced 2025-07-19 17:19:12 +00:00

[1.8.x] Fixed #26321 -- Added missing "for_save" parameter in expressions example.

Thanks tomaszn for the patch.

Backport of de8a11ba18d5902c668d4db47c38c9c6bdf9c1da from master
This commit is contained in:
Tim Graham 2016-03-03 19:34:31 -05:00
parent e4be3c80a1
commit 8b891cf386

View File

@ -448,7 +448,7 @@ calling the appropriate methods on the wrapped expression.
Tells Django that this expression contains an aggregate and that a Tells Django that this expression contains an aggregate and that a
``GROUP BY`` clause needs to be added to the query. ``GROUP BY`` clause needs to be added to the query.
.. method:: resolve_expression(query=None, allow_joins=True, reuse=None, summarize=False) .. method:: resolve_expression(query=None, allow_joins=True, reuse=None, summarize=False, for_save=False)
Provides the chance to do any pre-processing or validation of Provides the chance to do any pre-processing or validation of
the expression before it's added to the query. ``resolve_expression()`` the expression before it's added to the query. ``resolve_expression()``
@ -579,11 +579,11 @@ Now we implement the pre-processing and validation. Since we do not have
any of our own validation at this point, we just delegate to the nested any of our own validation at this point, we just delegate to the nested
expressions:: expressions::
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False): def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
c = self.copy() c = self.copy()
c.is_summary = summarize c.is_summary = summarize
for pos, expression in enumerate(self.expressions): for pos, expression in enumerate(self.expressions):
c.expressions[pos] = expression.resolve_expression(query, allow_joins, reuse, summarize) c.expressions[pos] = expression.resolve_expression(query, allow_joins, reuse, summarize, for_save)
return c return c
Next, we write the method responsible for generating the SQL:: Next, we write the method responsible for generating the SQL::