Optimized ExclusionConstraint.validate() a bit.
References to excluded fields are omitted in the replacement_map, so there is no need to replace references before checking for exclusions.
This commit is contained in:
parent
fc0942ada4
commit
8533a6af8d
|
@ -202,16 +202,15 @@ class ExclusionConstraint(BaseConstraint):
|
||||||
for idx, (expression, operator) in enumerate(self.expressions):
|
for idx, (expression, operator) in enumerate(self.expressions):
|
||||||
if isinstance(expression, str):
|
if isinstance(expression, str):
|
||||||
expression = F(expression)
|
expression = F(expression)
|
||||||
if isinstance(expression, F):
|
if exclude:
|
||||||
if exclude and expression.name in exclude:
|
if isinstance(expression, F):
|
||||||
return
|
if expression.name in exclude:
|
||||||
rhs_expression = expression.replace_references(replacement_map)
|
return
|
||||||
else:
|
else:
|
||||||
rhs_expression = expression.replace_references(replacement_map)
|
for expr in expression.flatten():
|
||||||
if exclude:
|
|
||||||
for expr in rhs_expression.flatten():
|
|
||||||
if isinstance(expr, F) and expr.name in exclude:
|
if isinstance(expr, F) and expr.name in exclude:
|
||||||
return
|
return
|
||||||
|
rhs_expression = expression.replace_references(replacement_map)
|
||||||
# Remove OpClass because it only has sense during the constraint
|
# Remove OpClass because it only has sense during the constraint
|
||||||
# creation.
|
# creation.
|
||||||
if isinstance(expression, OpClass):
|
if isinstance(expression, OpClass):
|
||||||
|
|
Loading…
Reference in New Issue