mirror of
https://github.com/django/django.git
synced 2025-08-06 11:58:26 +00:00
Fixed #32858 -- Fixed ExclusionConstraint crash with index transforms in expressions.
This commit is contained in:
parent
501a371411
commit
b69b0c3fe8
3 changed files with 20 additions and 1 deletions
|
@ -2,6 +2,7 @@ from django.db import NotSupportedError
|
|||
from django.db.backends.ddl_references import Statement, Table
|
||||
from django.db.models import Deferrable, F, Q
|
||||
from django.db.models.constraints import BaseConstraint
|
||||
from django.db.models.expressions import Col
|
||||
from django.db.models.sql import Query
|
||||
|
||||
__all__ = ['ExclusionConstraint']
|
||||
|
@ -73,6 +74,8 @@ class ExclusionConstraint(BaseConstraint):
|
|||
expression = F(expression)
|
||||
expression = expression.resolve_expression(query=query)
|
||||
sql, params = compiler.compile(expression)
|
||||
if not isinstance(expression, Col):
|
||||
sql = f'({sql})'
|
||||
try:
|
||||
opclass = self.opclasses[idx]
|
||||
if opclass:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue