diff options
| author | Simon Charette <charette.s@gmail.com> | 2024-02-19 00:20:13 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-02-29 12:22:17 +0100 |
| commit | f82c67aa217c8dd4320ef697b04a6da1681aa799 (patch) | |
| tree | d48d1a748c81269c3bc18cc5c25395da7096eb5e /django/contrib/postgres | |
| parent | 0fb104dda287431f5ab74532e45e8471e22b58c8 (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.py | 8 |
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 |
