Fix AttributeError when creating EmbeddedDocument
When an EmbeddedDocument is initialized with positional arguments, the document attempts to read _auto_id_field attribute which may not exist and would throw an AttributeError exception and fail the initialization. This change and the test is based on the discussion in issue #681 and PR #777 with a number of community members.
This commit is contained in:
@@ -51,7 +51,7 @@ class BaseDocument(object):
|
||||
# We only want named arguments.
|
||||
field = iter(self._fields_ordered)
|
||||
# If its an automatic id field then skip to the first defined field
|
||||
if self._auto_id_field:
|
||||
if getattr(self, '_auto_id_field', False):
|
||||
next(field)
|
||||
for value in args:
|
||||
name = next(field)
|
||||
|
||||
Reference in New Issue
Block a user