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
.find_one().inc()
.find_one().set()
Describe the bug Typing for .inc / .set is wrong when chained after .find_one.
.inc
.set
.find_one
To Reproduce
from beanie import Document, PydanticObjectId, init_beanie from motor.motor_asyncio import AsyncIOMotorClient class ShortIdCounter(Document): value: int async def main(): MONGODB_CONNECTION_STRING = "mongodb://localhost" NEW_DB_NAME = "tmp-test" client = AsyncIOMotorClient(MONGODB_CONNECTION_STRING) await client.drop_database(NEW_DB_NAME) await init_beanie( database=client[NEW_DB_NAME], document_models=[ ShortIdCounter, ], ) id = PydanticObjectId() await ShortIdCounter(id=id, value=1).create() counter = await ShortIdCounter.find_one(ShortIdCounter.id == id).inc( {ShortIdCounter.value: 1}, ) print(counter) if __name__ == "__main__": import asyncio asyncio.run(main())
Expected behavior
Expect counter to be an ShortIdCounter instance that contains the updated value, but got UpdateResult, which does not match the typing.
counter
ShortIdCounter
UpdateResult
Additional context
Beanie version: v1.29.0
v1.29.0
The behavior also mismatches the example in the documention: https://beanie-odm.dev/tutorial/updating-%26-deleting/#update-queries, which means either the typing and the documentation are both wrong or the implementation is wrong.
The text was updated successfully, but these errors were encountered:
This issue is stale because it has been open 30 days with no activity.
Sorry, something went wrong.
No branches or pull requests
Describe the bug
Typing for
.inc
/.set
is wrong when chained after.find_one
.To Reproduce
Expected behavior
Expect
counter
to be anShortIdCounter
instance that contains the updated value, but gotUpdateResult
, which does not match the typing.Additional context
Beanie version:
v1.29.0
The behavior also mismatches the example in the documention: https://beanie-odm.dev/tutorial/updating-%26-deleting/#update-queries, which means either the typing and the documentation are both wrong or the implementation is wrong.
The text was updated successfully, but these errors were encountered: