Describe the bug
A clear and concise description of what the bug is.
.model_dump tries to call the .model_dump method of a pydantic model which is embedded inside a Beanie Document, which is not yet an actual pydantic model, but instead a NotAnObject. As a workaround, we are referencing the parameter which forces the data to be parsed.
Interestingly, we do not see this behavior with the include parameter on .model_dump, and instead it works as expected.
To Reproduce
class SubCollection(BaseModel):
something: str
class Collection(Document):
name: str
sub: SubCollection
item = await Collection.find_one(Collection.id == id, fetch_links=True, lazy_parse=True)
return item.model_dump(exclude={"name":True})
Exception:
pydantic_core._pydantic_core.PydanticSerializationError: Error calling function `<lambda>`: AttributeError: 'NotAnObject' object has no attribute 'model_dump'
Describe the bug A clear and concise description of what the bug is.
.model_dump tries to call the .model_dump method of a pydantic model which is embedded inside a Beanie Document, which is not yet an actual pydantic model, but instead a NotAnObject. As a workaround, we are referencing the parameter which forces the data to be parsed.
Interestingly, we do not see this behavior with the include parameter on .model_dump, and instead it works as expected.
To Reproduce
Exception:
This, however, works:
Expected behavior We are expecting it to return a dictionary with all the keys except for "name"