tortoise / tortoise-orm

Familiar asyncio ORM for python, built with relations in mind
https://tortoise.github.io
Apache License 2.0
4.58k stars 378 forks source link

atomic bug #1497

Closed xalteropsx closed 11 months ago

xalteropsx commented 11 months ago

async def create_user(user: UserIn_PY):
    async with atomic():
        user_obj = Users.create(**user.model_dump(exclude_unset=True))
        return await User_PY.from_tortoise_orm(user_obj)

    await self.app(scope, receive, send)
  File "X:\sad\practice\Office\Backend\Electroapi\.venv\lib\site-packages\starlette\routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "X:\sad\practice\Office\Backend\Electroapi\.venv\lib\site-packages\starlette\routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "X:\sad\practice\Office\Backend\Electroapi\.venv\lib\site-packages\starlette\routing.py", line 66, in app
    response = await func(request)
  File "X:\sad\practice\Office\Backend\Electroapi\.venv\lib\site-packages\fastapi\routing.py", line 273, in app
    raw_response = await run_endpoint_function(
  File "X:\sad\practice\Office\Backend\Electroapi\.venv\lib\site-packages\fastapi\routing.py", line 190, in run_endpoint_function
    return await dependant.call(**values)
  File "X:\sad\practice\Office\Backend\Electroapi\Router\Tortoise.py", line 22, in create_user
    async with atomic():
AttributeError: __aenter__