tiangolo / sqlmodel

SQL databases in Python, designed for simplicity, compatibility, and robustness.
https://sqlmodel.tiangolo.com/
MIT License
13.7k stars 616 forks source link

a very terribale bug #399

Closed MrYZhou closed 1 year ago

MrYZhou commented 1 year ago

First Check

Commit to Help

Example Code

@router.get("/list",status_code=200)
async def index():
    with Session(engine) as session:
        list = session.exec(select(Config).offset(0).limit(100)).all()
        return list

Description

it can not response a result, a very strange phenomenon. At the command line, the request url has been regnized by fastapi,but can not into breakline. without any error info.

finaly,i change the request method with post,it work. it is so unreasonable. It is worth mentioning that the way can work normally in other router file.

Operating System

Windows

Operating System Details

No response

SQLModel Version

latest

Python Version

3.10.5

Additional Context

Consider that bugs are hard to reproduce,this is my demo url.

about demo path: router/generate.py @router.get("/list",status_code=200) async def index(): with Session(engine) as session: list = session.exec(select(Config).offset(0).limit(100)).all() return list

[https://github.com/MrYZhou/fastapi-le.git](demo url)

meirdev commented 1 year ago

This is because:

@router.get("/{id}", tags=["web", "app"])
async def index(id):
    pass

move it under /list:

@router.get("/list",status_code=200)
async def index():
    ...

@router.get("/{id}", tags=["web", "app"])
async def index(id):
    ...

The pattern "/{id}" catch "/list"

MrYZhou commented 1 year ago

thanks very much , list was regnized as a id value

MrYZhou commented 1 year ago

This is because:

@router.get("/{id}", tags=["web", "app"])
async def index(id):
    pass

move it under /list:

@router.get("/list",status_code=200)
async def index():
    ...

@router.get("/{id}", tags=["web", "app"])
async def index(id):
    ...

The pattern "/{id}" catch "/list"

thanks very much,