You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the existing issues and didn't find my bug already reported there
I have checked that my bug is still present in the latest release
Sqlacodegen version
master branch as of 2025.Febr.26 11:14 UTC
SQLAlchemy version
2.0.38
RDBMS vendor
MSSQL
What happened?
The SQLModel does not include foreign_keys argument in Relationships. This resulted in a AmbiguousForeignKeysError as I have multiple columns that are foreign keys on the same table.
-- I cannot share the exact tables as per company policy, but something similar should cause the same issueCREATETABLEdbo.Points
(
id int identity NOT NULL,
CONSTRAINT PK_Points PRIMARY KEY (id)
)
CREATETABLEdbo.Lines
(
id int identity NOT NULL,
point_a_id intNOT NULLCONSTRAINT FK__POINT_A__Lines__Points REFERENCESdbo.Points(id),
point_b_id intNOT NULLCONSTRAINT FK__POINT_B__Lines__Points REFERENCESdbo.Points(id),
CONSTRAINT PK_Lines PRIMARY KEY (id)
)
The text was updated successfully, but these errors were encountered:
Things to check first
I have searched the existing issues and didn't find my bug already reported there
I have checked that my bug is still present in the latest release
Sqlacodegen version
master branch as of 2025.Febr.26 11:14 UTC
SQLAlchemy version
2.0.38
RDBMS vendor
MSSQL
What happened?
The SQLModel does not include
foreign_keys
argument in Relationships. This resulted in aAmbiguousForeignKeysError
as I have multiple columns that are foreign keys on the same table.Here are the results on the
Lines
table:Generated by SQLModelGenerator:
Generated by DeclarativeGenerator:
Manual solution for SQLModel (or something similar):
Note: These are not exact tables I'm working with, but due to a company policy and confidentiality I cannot share that, so these are similar examples
Potential solution idea:
Use the
sa_relationship
arg inRelationship()
with output generated with the Declarative Generator:Database schema for reproducing the bug
The text was updated successfully, but these errors were encountered: