mirror of
https://github.com/django/django.git
synced 2025-08-23 12:04:21 +00:00
Fixed #24509 -- Added Expression support to SQLInsertCompiler
This commit is contained in:
parent
6e51d5d0e5
commit
134ca4d438
15 changed files with 247 additions and 67 deletions
|
@ -180,6 +180,13 @@ class BaseExpression(object):
|
|||
return True
|
||||
return False
|
||||
|
||||
@cached_property
|
||||
def contains_column_references(self):
|
||||
for expr in self.get_source_expressions():
|
||||
if expr and expr.contains_column_references:
|
||||
return True
|
||||
return False
|
||||
|
||||
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
|
||||
"""
|
||||
Provides the chance to do any preprocessing or validation before being
|
||||
|
@ -339,6 +346,17 @@ class BaseExpression(object):
|
|||
def reverse_ordering(self):
|
||||
return self
|
||||
|
||||
def flatten(self):
|
||||
"""
|
||||
Recursively yield this expression and all subexpressions, in
|
||||
depth-first order.
|
||||
"""
|
||||
yield self
|
||||
for expr in self.get_source_expressions():
|
||||
if expr:
|
||||
for inner_expr in expr.flatten():
|
||||
yield inner_expr
|
||||
|
||||
|
||||
class Expression(BaseExpression, Combinable):
|
||||
"""
|
||||
|
@ -613,6 +631,9 @@ class Random(Expression):
|
|||
|
||||
|
||||
class Col(Expression):
|
||||
|
||||
contains_column_references = True
|
||||
|
||||
def __init__(self, alias, target, output_field=None):
|
||||
if output_field is None:
|
||||
output_field = target
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue