Better fix for .save() _delta issue with DbRefs
refs: hmarr/mongoengine#518
This commit is contained in:
		| @@ -1043,18 +1043,12 @@ Invalid data to create a `%s` instance.\n%s""".strip() % (cls._class_name, error | ||||
|             for path in set_fields: | ||||
|                 parts = path.split('.') | ||||
|                 d = doc | ||||
|                 dbref = False | ||||
|                 for p in parts: | ||||
|                     if isinstance(d, DBRef): | ||||
|                         dbref = True | ||||
|                     elif hasattr(d, '__getattr__'): | ||||
|                         d = getattr(p, d) | ||||
|                     elif p.isdigit(): | ||||
|                     if p.isdigit(): | ||||
|                         d = d[int(p)] | ||||
|                     else: | ||||
|                         d = d.get(p) | ||||
|                 if not dbref: | ||||
|                     set_data[path] = d | ||||
|                 set_data[path] = d | ||||
|         else: | ||||
|             set_data = doc | ||||
|             if '_id' in set_data: | ||||
|   | ||||
| @@ -226,6 +226,7 @@ class Document(BaseDocument): | ||||
|                 if cascade_kwargs:  # Allow granular control over cascades | ||||
|                     kwargs.update(cascade_kwargs) | ||||
|                 kwargs['_refs'] = _refs | ||||
|                 self._changed_fields = [] | ||||
|                 self.cascade_save(**kwargs) | ||||
|  | ||||
|         except pymongo.errors.OperationFailure, err: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user