summaryrefslogtreecommitdiff
path: root/django/contrib/postgres
diff options
context:
space:
mode:
authorElizabethU <elizabeth.uselton@gmail.com>2019-09-02 19:09:31 -0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-10-01 17:58:19 +0200
commit54ea290e5bbd19d87bd8dba807738eeeaf01a362 (patch)
treed83c186bde9f50faa13840e6ee227e3bb1e02ad6 /django/contrib/postgres
parent6475e6318c970359a2f02798910a917229ee17d7 (diff)
Fixed #30651 -- Made __eq__() methods return NotImplemented for not implemented comparisons.
Changed __eq__ to return NotImplemented instead of False if compared to an object of the same type, as is recommended by the Python data model reference. Now these models can be compared to ANY (or other objects with __eq__ overwritten) without returning False automatically.
Diffstat (limited to 'django/contrib/postgres')
-rw-r--r--django/contrib/postgres/constraints.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/django/contrib/postgres/constraints.py b/django/contrib/postgres/constraints.py
index 2fcb076ecf..67e415ddcf 100644
--- a/django/contrib/postgres/constraints.py
+++ b/django/contrib/postgres/constraints.py
@@ -89,13 +89,14 @@ class ExclusionConstraint(BaseConstraint):
return path, args, kwargs
def __eq__(self, other):
- return (
- isinstance(other, self.__class__) and
- self.name == other.name and
- self.index_type == other.index_type and
- self.expressions == other.expressions and
- self.condition == other.condition
- )
+ if isinstance(other, self.__class__):
+ return (
+ self.name == other.name and
+ self.index_type == other.index_type and
+ self.expressions == other.expressions and
+ self.condition == other.condition
+ )
+ return super().__eq__(other)
def __repr__(self):
return '<%s: index_type=%s, expressions=%s%s>' % (