MCPcopy
hub / github.com/django/django / resolve_expression

Method resolve_expression

django/db/models/expressions.py:279–315  ·  view source on GitHub ↗

Provide the chance to do any preprocessing or validation before being added to the query. Arguments: * query: the backend query implementation * allow_joins: boolean allowing or denying use of joins in this query * reuse: a set of reusa

(
        self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False
    )

Source from the content-addressed store, hash-verified

277 )
278
279 def resolve_expression(
280 self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False
281 ):
282 """
283 Provide the chance to do any preprocessing or validation before being
284 added to the query.
285
286 Arguments:
287 * query: the backend query implementation
288 * allow_joins: boolean allowing or denying use of joins
289 in this query
290 * reuse: a set of reusable joins for multijoins
291 * summarize: a terminal aggregate clause
292 * for_save: whether this expression about to be used in a save or
293 update
294
295 Return: an Expression to be added to the query.
296 """
297 c = self.copy()
298 c.is_summary = summarize
299 source_expressions = [
300 (
301 expr.resolve_expression(query, allow_joins, reuse, summarize, for_save)
302 if expr is not None
303 else None
304 )
305 for expr in c.get_source_expressions()
306 ]
307 if not self.allows_composite_expressions and any(
308 isinstance(expr, ColPairs) for expr in source_expressions
309 ):
310 raise ValueError(
311 f"{self.__class__.__name__} expression does not support "
312 "composite primary keys."
313 )
314 c.set_source_expressions(source_expressions)
315 return c
316
317 @property
318 def conditional(self):

Callers

nothing calls this directly

Calls 4

copyMethod · 0.95
resolve_expressionMethod · 0.45

Tested by

no test coverage detected