-
-
Notifications
You must be signed in to change notification settings - Fork 715
Relationship attribute not in model schema #255
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 it's useful,you can see the doc :https://sqlmodel.tiangolo.com/tutorial/fastapi/relationships/ |
Hey @carlosporta! |
@AdamMisiak I installed version 1.4.35 and it fixed my issue, hope it fixes yours too! |
same issue here |
Hey there @carlosporta! You need to declare a model that explicitly includes the children for the As @4linuxfun says, you can read the docs explaining it, the relevant section is here: https://sqlmodel.tiangolo.com/tutorial/fastapi/relationships/#dont-include-all-the-data About the issue mentioned by @alp09, that one is reported here: #315, it was solved here: #322, it will be available in the next version, in a couple of hours, SQLModel |
Currently what I did is:
Also there is a method I've written for pagination that is available for table=True objects, which returns So as you understand that's not the ideal solution. Also I've looked into the code and as I understand you don't add Relation fields as real fields that's why it doesn't work, but in fact there is no need to load relations by default cause it leads to the extra DB requests, so maybe it does make sense to limit recursion level ( for example, as it's done in sqlalchemy - |
First Check
Commit to Help
Example Code
Description
I have two related models (one parent to many children). And that relationship is eager, as you can see when I select a parent and print it, it is possible to see its children too. But the problem happens when I want to cast the result from the select statement to a parent model, using for example the from_orm function, because there is no attribute named children on the parent schema. My problem is probably related to this issue: #224.
Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.6
Python Version
3.10.2
Additional Context
No response
The text was updated successfully, but these errors were encountered: