summaryrefslogtreecommitdiff
path: root/tests/postgres_tests
diff options
context:
space:
mode:
authorMaxim Petrov <maximpetrov@yahoo.com>2020-08-19 05:22:12 +0300
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-08-19 06:43:54 +0200
commitbf6d07730c41ae23836d8dae98626fe8614307e2 (patch)
tree9abb04e5bd1631fdd6c58ef35a6d286627ec1289 /tests/postgres_tests
parente2e34f4de3b90f3820ee11d49cc369ef573bc2ef (diff)
Fixed #31902 -- Fixed crash of ExclusionConstraint on expressions with params.
Diffstat (limited to 'tests/postgres_tests')
-rw-r--r--tests/postgres_tests/test_constraints.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_constraints.py b/tests/postgres_tests/test_constraints.py
index 7d79e65239..89463650e8 100644
--- a/tests/postgres_tests/test_constraints.py
+++ b/tests/postgres_tests/test_constraints.py
@@ -7,6 +7,7 @@ from django.db import (
from django.db.models import (
CheckConstraint, Deferrable, F, Func, Q, UniqueConstraint,
)
+from django.db.models.functions import Left
from django.test import skipUnlessDBFeature
from django.utils import timezone
@@ -608,6 +609,17 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
editor.remove_constraint(RangesModel, constraint)
self.assertNotIn(constraint_name, self.get_constraints(RangesModel._meta.db_table))
+ def test_expressions_with_params(self):
+ constraint_name = 'scene_left_equal'
+ self.assertNotIn(constraint_name, self.get_constraints(Scene._meta.db_table))
+ constraint = ExclusionConstraint(
+ name=constraint_name,
+ expressions=[(Left('scene', 4), RangeOperators.EQUAL)],
+ )
+ with connection.schema_editor() as editor:
+ editor.add_constraint(Scene, constraint)
+ self.assertIn(constraint_name, self.get_constraints(Scene._meta.db_table))
+
def test_range_adjacent_initially_deferred(self):
constraint_name = 'ints_adjacent_deferred'
self.assertNotIn(constraint_name, self.get_constraints(RangesModel._meta.db_table))