mirror of
https://github.com/django/django.git
synced 2026-02-09 02:49:25 +08:00
Fixed #36852 -- Ignored index_type case in ExclusionConstraint equality check.
This commit is contained in:
@@ -148,7 +148,7 @@ class ExclusionConstraint(CheckPostgresInstalledMixin, BaseConstraint):
|
||||
if isinstance(other, self.__class__):
|
||||
return (
|
||||
self.name == other.name
|
||||
and self.index_type == other.index_type
|
||||
and self.index_type.lower() == other.index_type.lower()
|
||||
and self.expressions == other.expressions
|
||||
and self.condition == other.condition
|
||||
and self.deferrable == other.deferrable
|
||||
|
||||
@@ -535,6 +535,24 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
|
||||
],
|
||||
include=["cancelled"],
|
||||
)
|
||||
constraint_8 = ExclusionConstraint(
|
||||
index_type="gist",
|
||||
name="exclude_overlapping",
|
||||
expressions=[
|
||||
("datespan", RangeOperators.OVERLAPS),
|
||||
("room", RangeOperators.EQUAL),
|
||||
],
|
||||
include=["cancelled"],
|
||||
)
|
||||
constraint_9 = ExclusionConstraint(
|
||||
index_type="GIST",
|
||||
name="exclude_overlapping",
|
||||
expressions=[
|
||||
("datespan", RangeOperators.OVERLAPS),
|
||||
("room", RangeOperators.EQUAL),
|
||||
],
|
||||
include=["cancelled"],
|
||||
)
|
||||
constraint_10 = ExclusionConstraint(
|
||||
name="exclude_overlapping",
|
||||
expressions=[
|
||||
@@ -572,6 +590,8 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
|
||||
self.assertNotEqual(constraint_2, constraint_3)
|
||||
self.assertNotEqual(constraint_2, constraint_4)
|
||||
self.assertNotEqual(constraint_2, constraint_7)
|
||||
self.assertEqual(constraint_7, constraint_8)
|
||||
self.assertEqual(constraint_7, constraint_9)
|
||||
self.assertNotEqual(constraint_4, constraint_5)
|
||||
self.assertNotEqual(constraint_5, constraint_6)
|
||||
self.assertNotEqual(constraint_1, object())
|
||||
|
||||
Reference in New Issue
Block a user