Partitioned tables with composite primary keys and composite foreign keys compatible with Relationship()? #838
Unanswered
perearnantgx
asked this question in
Questions
Replies: 0 comments
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
I have two tables in a postgreSQL database: Parent and Child. Both of them are partitioned with the column
version_id
(int).The description of the PKs and FKs can be read from the Example Code.
When I try to set a Relationship in SQLModel between the two tables I got this error message:
sqlalchemy.exc.NoForeignKeysError: Could not determine join condition between parent/child tables on relationship Master_Partition.hotels - there are no foreign keys linking these tables. Ensure that referencing columns are associated with a ForeignKey or ForeignKeyConstraint, or specify a 'primaryjoin' expression.
I tried using the arguments
primaryjoin
andforeign_keys
inRelationship()
but they seem not to be compatible.I tried using the arguments
primaryjoin
andforeign_keys
in sqlalchemyrelationship()
, but then I have problems with theClass
declaration.Is there a way in SQLModel to do this using Relationship?
Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.16
Python Version
3.12.2
Additional Context
This issue is very similar #222
but it does not seem to work for me
Beta Was this translation helpful? Give feedback.
All reactions