Skip to content

Commit 805f483

Browse files
author
Jassin Meknassi
committed
only a val to deref list if DBREf exists: prevents crashing on dead DBRefs and set the db correctly
1 parent 6998936 commit 805f483

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mongoengine/fields.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ def __get__(self, instance, owner):
308308
# Dereference DBRefs
309309
if isinstance(value, (pymongo.dbref.DBRef)):
310310
value = _get_db().dereference(value)
311-
deref_list.append(referenced_type._from_son(value))
311+
if value:
312+
deref_list.append(referenced_type._from_son(value))
312313
else:
313314
deref_list.append(value)
314315
instance._data[self.name] = deref_list

0 commit comments

Comments
 (0)