summaryrefslogtreecommitdiff
path: root/django/contrib/postgres
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2024-02-19 00:20:13 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2024-02-29 12:22:17 +0100
commitf82c67aa217c8dd4320ef697b04a6da1681aa799 (patch)
treed48d1a748c81269c3bc18cc5c25395da7096eb5e /django/contrib/postgres
parent0fb104dda287431f5ab74532e45e8471e22b58c8 (diff)
Fixed #35234 -- Added system checks for invalid model field names in ExclusionConstraint.expressions.
Diffstat (limited to 'django/contrib/postgres')
-rw-r--r--django/contrib/postgres/constraints.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/django/contrib/postgres/constraints.py b/django/contrib/postgres/constraints.py
index c61072b5a5..ff702c53b0 100644
--- a/django/contrib/postgres/constraints.py
+++ b/django/contrib/postgres/constraints.py
@@ -77,6 +77,14 @@ class ExclusionConstraint(BaseConstraint):
expressions.append(expression)
return ExpressionList(*expressions).resolve_expression(query)
+ def _check(self, model, connection):
+ references = set()
+ for expr, _ in self.expressions:
+ if isinstance(expr, str):
+ expr = F(expr)
+ references.update(model._get_expr_references(expr))
+ return self._check_references(model, references)
+
def _get_condition_sql(self, compiler, schema_editor, query):
if self.condition is None:
return None