diff options
author | ElizabethU <elizabeth.uselton@gmail.com> | 2019-09-02 19:09:31 -0700 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-10-01 17:58:19 +0200 |
commit | 54ea290e5bbd19d87bd8dba807738eeeaf01a362 (patch) | |
tree | d83c186bde9f50faa13840e6ee227e3bb1e02ad6 /django/db/models/query_utils.py | |
parent | 6475e6318c970359a2f02798910a917229ee17d7 (diff) | |
download | django-54ea290e5bbd19d87bd8dba807738eeeaf01a362.tar.gz |
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/db/models/query_utils.py')
-rw-r--r-- | django/db/models/query_utils.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py index 7a667814f4..189fb4fa44 100644 --- a/django/db/models/query_utils.py +++ b/django/db/models/query_utils.py @@ -309,8 +309,9 @@ class FilteredRelation: self.path = [] def __eq__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented return ( - isinstance(other, self.__class__) and self.relation_name == other.relation_name and self.alias == other.alias and self.condition == other.condition |