-
Notifications
You must be signed in to change notification settings - Fork 122
find method does not work #322
New issue
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
Comments
I think you forgot to run migrations first: from fastapi import FastAPI
from redis_om import (
Migrator
)
app = FastAPI(title=__name__)
@app.on_event("startup")
async def startup():
await Migrator().run() Update: Hey @johnson2427, i tried to run your code after running migrations, this time, i am getting the following error: pydantic.error_wrappers.ValidationError: 1 validation error for Item
id
field required (type=value_error.missing Removed the id field, and the endpoint works fine: It seems like redis-om-python/aredis_om/model/model.py Lines 1094 to 1106 in dcd84e0
|
@wiseaidev Thank you! This let's me narrow it down, but renaming that |
Hey @johnson2427, just giving it a id: int = Field(index=True, default=0) I dunno how it works. MAGIC. Update: I think there is a bug in the The only workaround, for now, is to rename the field to id_: str = Field(index=True) In the meantime, I am trying to locate the bug. |
Y'all would laugh so hard if i should you the bug: redis-om-python/aredis_om/model/model.py Lines 1210 to 1213 in dcd84e0
It seems like the developer was trying to implement something, didn't like it, then forgot about removing the code. LOl |
Time to run: git blame aredis_om/model/model.py -L 1210,1213 0990c2e1 redis_developer/orm/model.py (Andrew Brookins 2021-09-15 17:41:45 -0700 1210) try:
d2fa4c58 redis_developer/model/model.py (Andrew Brookins 2021-10-20 13:01:46 -0700 1211) del fields["id"]
0990c2e1 redis_developer/orm/model.py (Andrew Brookins 2021-09-15 17:41:45 -0700 1212) except KeyError:
0990c2e1 redis_developer/orm/model.py (Andrew Brookins 2021-09-15 17:41:45 -0700 1213) pass
(END) Ayo, Andrew! |
hahahha, been there done that, no worries. I thought I was going insane. And I added the |
@simonprickett seems like this issues has had a bug fix already merged in and can be closed |
What is the issue
I have created a FastAPI application, and I am trying to integrate aredis_om (but this fails with redis_om as well) with one of my rest endpoint modules.
I created a model called
Item
:As you can see in my endpoints file, I had to make a workaround to be able to pull the individual item, and to be able to get a list of items from Redis. My last endpoint, I believe is just wrong, I have to change id to a pk in order to get that item, so the last endpoint can be ignored.
My attempt for the first endpoint was this:
When I hit the endpoint with the .find() method I received a traceback of:
If you need more information from me, let me know! Thank you in advance.
The text was updated successfully, but these errors were encountered: