We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
root
Describe the bug Beanie persists root field in the database when using Pydantic RootModel. The root field must not be persisted in the database.
To Reproduce
from typing import List from motor.motor_asyncio import AsyncIOMotorClient from pydantic import RootModel from beanie import Document, init_beanie Pets = RootModel[List[str]] class PetDocument(Document): content: Pets async def example(): client = AsyncIOMotorClient("mongodb://user:pass@host:27017") await init_beanie(database=client.db_name, document_models=[PetDocument]) my_pets = PetDocument(content=["dog", "cat", "fish"]) await my_pets.insert() import asyncio asyncio.run(example())
Expected behavior In MongoDB it is expected to have record like
{"content": ["dog", "cat", "fish"]
but instead it stores it as
{"content": {"root":["dog", "cat", "fish"]}}
The text was updated successfully, but these errors were encountered:
Hi! Let me check this Pydantic feature and the doc.
Sorry, something went wrong.
Fixed in #669 . Please, try
This has been fixed in #669 . Thank you for looking into it!
No branches or pull requests
Describe the bug
Beanie persists root field in the database when using Pydantic RootModel. The root field must not be persisted in the database.
To Reproduce
Expected behavior
In MongoDB it is expected to have record like
but instead it stores it as
The text was updated successfully, but these errors were encountered: