Make python value for LazyReferenceFields be a DBRef
Previously, when reading a LazyReferenceField from the DB, it was stored internally in the parent document's _data field as an ObjectId. However, this meant that equality tests using an enclosing EmbeddedDocument would not return True when the EmbeddedDocument being compared to contained a DBRef or Document in _data. Enclosing Documents were largely unaffected because they look at the primary key for equality (which EmbeddedDocuments lack). This makes the internal Python representation of a LazyReferenceField (before the LazyReference itself has been constructed) a DBRef, using code identical to ReferenceField.
This commit is contained in:
		| @@ -3321,7 +3321,7 @@ class TestInstance(MongoDBTestCase): | ||||
|  | ||||
|     def test_embedded_document_equality_with_lazy_ref(self): | ||||
|         class Job(EmbeddedDocument): | ||||
|             boss = LazyReferenceField('Person') | ||||
|             boss = LazyReferenceField("Person") | ||||
|  | ||||
|         class Person(Document): | ||||
|             job = EmbeddedDocumentField(Job) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user