I used the GitHub search to find a similar issue and didn't find it.
I searched the SQLModel documentation, with the integrated search.
I already searched in Google "How to X in SQLModel" and didn't find any information.
I already read and followed all the tutorial in the docs and didn't find an answer.
I already checked if it is not related to SQLModel but to Pydantic.
I already checked if it is not related to SQLModel but to SQLAlchemy.
Commit to Help
I commit to help with one of those options 👆
Example Code
fromfastapiimportFastAPI, Queryapp=FastAPI()
@app.get("/posts-lte/")defget_posts_lte(limit: int=Query(1, lte=5)):
""" `lte` seems not working """return {"limit": limit}
@app.get("/posts-lt/")defget_posts_lt(limit: int=Query(1, lt=5)):
""" `lt` works """return {"limit": limit}
Description
Maybe this issue is more related to FastAPI, but I found this issue from SQLModel tutorial, so I reckon it's better to report here.
The tutorial uses lte for Query Parameters, but it seems not working (I can still get the query result if the limit is set to higher than lte constraint). However, if I tried to use lt, then it works fine.
Meanwhile, I didn't find the usage of lte for Query Parameters in the FastAPI documentations.
As a result, I'm not sure whether this is a bug or FastAPI just doesn't support this operation .
Activity
ashleney commented on Dec 29, 2021
Shouldn't it actually be le instead? That's what pydantic uses and I doubt it has changed in sqlmodel.
jrycw commented on Dec 29, 2021
@thesadru Thanks for the reply. I think you're correct. Maybe it is just a typo in code.
tiangolo commented on Oct 23, 2023
Good catch, thank you @jrycw! And thanks for the PR! 🙇 ☕
github-actions commented on Nov 3, 2023
Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs.