diff options
author | Simon Charette <charette.s@gmail.com> | 2022-08-10 07:51:07 -0400 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-08-11 09:53:10 +0200 |
commit | 35911078fa40eb35859832987fedada76963c01e (patch) | |
tree | 01e9da78e83ef5f15e754319e3407bd85bbfb3b0 /django/contrib/postgres/constraints.py | |
parent | 8533a6af8d937d487dd4a9f5c40ac98e111915a8 (diff) | |
download | django-35911078fa40eb35859832987fedada76963c01e.tar.gz |
Replaced Expression.replace_references() with .replace_expressions().
The latter allows for more generic use cases beyond the currently
limited ones constraints validation has.
Refs #28333, #30581.
Diffstat (limited to 'django/contrib/postgres/constraints.py')
-rw-r--r-- | django/contrib/postgres/constraints.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/django/contrib/postgres/constraints.py b/django/contrib/postgres/constraints.py index c67292f9f0..8b76de3c42 100644 --- a/django/contrib/postgres/constraints.py +++ b/django/contrib/postgres/constraints.py @@ -198,6 +198,7 @@ class ExclusionConstraint(BaseConstraint): replacement_map = instance._get_field_value_map( meta=model._meta, exclude=exclude ) + replacements = {F(field): value for field, value in replacement_map.items()} lookups = [] for idx, (expression, operator) in enumerate(self.expressions): if isinstance(expression, str): @@ -210,7 +211,7 @@ class ExclusionConstraint(BaseConstraint): for expr in expression.flatten(): if isinstance(expr, F) and expr.name in exclude: return - rhs_expression = expression.replace_references(replacement_map) + rhs_expression = expression.replace_expressions(replacements) # Remove OpClass because it only has sense during the constraint # creation. if isinstance(expression, OpClass): |