SQLModel "Person" with multiple attributes of the same SQLModel "Address" without a list #793
Unanswered
mariusbrinkmann
asked this question in
Questions
Replies: 1 comment
-
I would be interested if there is a "more native" way to do this, but I got it to work by using sql alchemy primaryjoin
|
Beta Was this translation helpful? Give feedback.
0 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
Address
model that should be a tablePerson
model that should be a table and has two attributeshome_address
andwork_address
both of the same typeAddress
Person
shouldperson
tableaddress
table representing thePerson
instance'shome_address
andwork_address
address
table with the row in theperson
tableExecuting the minimum working example does not work as the relationship between the to tables is missing. What's the correct approach to create models like this if I want to keep two separate attributes instead of
addresses: List[Address]
? Is a link table with atype
column (home
orwork
) the correct approach?Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.14
Python Version
3.10.11
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions