Fixed hashing of EmbeddedDocuments (#348)
This commit is contained in:
parent
ce44843e27
commit
a246154961
@ -5,6 +5,7 @@ Changelog
|
|||||||
|
|
||||||
Changes in 0.8.2
|
Changes in 0.8.2
|
||||||
================
|
================
|
||||||
|
- Fixed hashing of EmbeddedDocuments (#348)
|
||||||
- Added lock when calling doc.Delete() for when signals have no sender (#350)
|
- Added lock when calling doc.Delete() for when signals have no sender (#350)
|
||||||
- Reload forces read preference to be PRIMARY (#355)
|
- Reload forces read preference to be PRIMARY (#355)
|
||||||
- Querysets are now lest restrictive when querying duplicate fields (#332, #333)
|
- Querysets are now lest restrictive when querying duplicate fields (#332, #333)
|
||||||
|
@ -215,7 +215,7 @@ class BaseDocument(object):
|
|||||||
return not self.__eq__(other)
|
return not self.__eq__(other)
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
if self.pk is None:
|
if getattr(self, 'pk', None) is None:
|
||||||
# For new object
|
# For new object
|
||||||
return super(BaseDocument, self).__hash__()
|
return super(BaseDocument, self).__hash__()
|
||||||
else:
|
else:
|
||||||
|
@ -1705,6 +1705,14 @@ class InstanceTest(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertTrue(u1 in all_user_set)
|
self.assertTrue(u1 in all_user_set)
|
||||||
|
|
||||||
|
def test_embedded_document_hash(self):
|
||||||
|
"""Test embedded document can be hashed
|
||||||
|
"""
|
||||||
|
class User(EmbeddedDocument):
|
||||||
|
pass
|
||||||
|
|
||||||
|
hash(User())
|
||||||
|
|
||||||
def test_picklable(self):
|
def test_picklable(self):
|
||||||
|
|
||||||
pickle_doc = PickleTest(number=1, string="One", lists=['1', '2'])
|
pickle_doc = PickleTest(number=1, string="One", lists=['1', '2'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user