-
Notifications
You must be signed in to change notification settings - Fork 228
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
[BUG] AttributeError: get_motor_collection when setting fetch_links=True #1056
Comments
This issue is stale because it has been open 30 days with no activity. |
This issue was closed because it has been stalled for 14 days with no activity. |
I want to keep this issue open. Could someone confirm this bug? Or is it the problem from my side? |
Hi @tdoan2010, |
Thank you for your reply and your work! I think it's fine that it only works with Pydantic v2. At some point, one needs to upgrade Pydantic anyway. |
Describe the bug
AttributeError: get_motor_collection
when settingfetch_links=True
.To Reproduce
I'm using Beanie with FastAPI. For example, my Beanie models look like this:
When getting a
Project
by ID, I also want to prefetch its relateditems
. So, my endpoint looks like this:But I got the error:
If I remove
fetch_links=True
and later on callthen it works fine.
I'm sure that the database was initialized properly because everything else works normally, only this
fetch_links
has problem. Just to be sure, here is how the database was initialized:This function is then called in the startup part of FastAPI:
So, did I miss something? Or it's a bug of Beanie? I'm using FastAPI 0.115.2 and Beanie 1.27.0.
Expected behavior
Document.get(id, fetch_links=True)
should work without error.The text was updated successfully, but these errors were encountered: