Closed Amaljyothi44 closed 2 weeks ago
Hey @Amaljyothi44 π
Thanks for raising the issue. Could you confirm your robyn version?
@sansyrox I have updated the version of Robyn I am using. The current version is robyn==0.54.5.
Hey @Amaljyothi44 π
One suggestion - please format code snippets using backticks(`) . But apart from that yes, this is definitely an issue. We could fix it like your suggestion, but maybe we can add a cast_to
in the request.query_params, which takes a python function callable and tries to cast it to data type.
( https://github.com/sparckles/Robyn/issues/836 )
e.g.
@app.get("/crimes")
async def get_crimes(request):
with SessionLocal() as db: # Use SessionLocal here
skip = request.query_params.get("skip",cast_to=int, default=0)
limit = request.query_params.get("limit", cast_to=int, default=100)
skip = int(skip)
limit = int(limit)
crimes = crud.get_crimes(db, skip=skip, limit=limit)
return crimes
What do you think of this approach?
Hey @Amaljyothi44 ,
The suggestion is to implement it π
@sansyrox ohhh, sorry π ,
I agree that using cast_to
in request.query_params
is a more efficient and cleaner approach.
@Amaljyothi44 , would you like to take that up?
@sansyrox Sure, I'm working on it.
Bug Description
There is an issue with the get_crimes endpoint in the crime data documentation. The code provided is throwing a TypeError when attempting to retrieve query parameters.
Steps to Reproduce
No response
Your operating system
None
Your Python version (
python --version
)Python 3.11.3
Your Robyn version
robyn==0.54.5
Additional Info
Corrected Code:
@sansyrox please CMIIW