When using autogenerated document ids in a sharded collection, do set that id back into the Document
This commit is contained in:
parent
f099dc6a37
commit
babbc8bcd6
@ -293,7 +293,7 @@ class Document(BaseDocument):
|
|||||||
raise NotUniqueError(message % unicode(err))
|
raise NotUniqueError(message % unicode(err))
|
||||||
raise OperationError(message % unicode(err))
|
raise OperationError(message % unicode(err))
|
||||||
id_field = self._meta['id_field']
|
id_field = self._meta['id_field']
|
||||||
if id_field not in self._meta.get('shard_key', []):
|
if created or id_field not in self._meta.get('shard_key', []):
|
||||||
self[id_field] = self._fields[id_field].to_python(object_id)
|
self[id_field] = self._fields[id_field].to_python(object_id)
|
||||||
|
|
||||||
self._clear_changed_fields()
|
self._clear_changed_fields()
|
||||||
|
@ -2281,6 +2281,8 @@ class InstanceTest(unittest.TestCase):
|
|||||||
log.machine = "Localhost"
|
log.machine = "Localhost"
|
||||||
log.save()
|
log.save()
|
||||||
|
|
||||||
|
self.assertIsNotNone(log.id)
|
||||||
|
|
||||||
log.log = "Saving"
|
log.log = "Saving"
|
||||||
log.save()
|
log.save()
|
||||||
|
|
||||||
@ -2304,6 +2306,8 @@ class InstanceTest(unittest.TestCase):
|
|||||||
log.machine = "Localhost"
|
log.machine = "Localhost"
|
||||||
log.save()
|
log.save()
|
||||||
|
|
||||||
|
self.assertIsNotNone(log.id)
|
||||||
|
|
||||||
log.log = "Saving"
|
log.log = "Saving"
|
||||||
log.save()
|
log.save()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user