parent
556e620c7a
commit
dc5a613bc7
@ -653,6 +653,9 @@ class GenericReferenceField(BaseField):
|
|||||||
return doc
|
return doc
|
||||||
|
|
||||||
def to_mongo(self, document):
|
def to_mongo(self, document):
|
||||||
|
if document is None:
|
||||||
|
return None
|
||||||
|
|
||||||
id_field_name = document.__class__._meta['id_field']
|
id_field_name = document.__class__._meta['id_field']
|
||||||
id_field = document.__class__._fields[id_field_name]
|
id_field = document.__class__._fields[id_field_name]
|
||||||
|
|
||||||
|
@ -1095,6 +1095,18 @@ class FieldTest(unittest.TestCase):
|
|||||||
Link.drop_collection()
|
Link.drop_collection()
|
||||||
User.drop_collection()
|
User.drop_collection()
|
||||||
|
|
||||||
|
def test_generic_reference_is_none(self):
|
||||||
|
|
||||||
|
class Person(Document):
|
||||||
|
name = StringField()
|
||||||
|
city = GenericReferenceField()
|
||||||
|
|
||||||
|
Person.drop_collection()
|
||||||
|
Person(name="Wilson Jr").save()
|
||||||
|
|
||||||
|
self.assertEquals(repr(Person.objects(city=None)),
|
||||||
|
"[<Person: Person object>]")
|
||||||
|
|
||||||
def test_binary_fields(self):
|
def test_binary_fields(self):
|
||||||
"""Ensure that binary fields can be stored and retrieved.
|
"""Ensure that binary fields can be stored and retrieved.
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user