unexpected behaviour: on commit fk turns into None and violates the constraints #897
Unanswered
giovanni-bellini-argo
asked this question in
Questions
Replies: 2 comments 20 replies
-
after some more tries i reached the conclusion that the problem is brought by the Relationship function |
Beta Was this translation helpful? Give feedback.
5 replies
-
Well, it's hard to reproduce your code as is, so here is what I suggest, I created an example project for you, you can find it here Briefly, here is what I did from what you send:
Some precisions:
I hope this will help you. Tell me if anything isn't clear or if you want some more help. |
Beta Was this translation helpful? Give feedback.
15 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
the whole logic works as expected but when executing the add function and committing the db session, suddenly, tenant_id is turned into None (i already checked that in all other passages it dosen't happen so i'm pretty sure the problem is somewhere in the commit function but couldn't find the cause).
i use the same logic on other models (basically the objective is to initialize the db with mappings) and that is the only case in which a fk is turned into None.
if i try to do the same but start from the parent class (aka. site.Site) then use model_validate to cast it to a siteSQL class and assign all the values, everything works as expected.
is to note that the fk is the only one being turned into None
Operating System
Linux
Operating System Details
Ubuntu 22.04.4 LTS
SQLModel Version
0.0.16
Python Version
Python 3.10.12
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions