Support Sqlmodel link models - #486
Open
sheinbergon wants to merge 4 commits into
Open
Conversation
Association tables that have a primary key are now generated as
`SQLModel` table classes (without relationships of their own) and
referenced from both sides via `Relationship(link_model=...)` instead of
`sa_relationship_kwargs={'secondary': ...}`, matching the idiom from the
SQLModel documentation. Link tables without a primary key cannot be
SQLModel classes and keep the previous plain `Table` output.
The link model classes are emitted before the classes referencing them,
since `link_model=` needs the class object rather than a string.
Fixes agronholm#405
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Opts out of rendering association tables as link model classes, keeping the previous plain Table + secondary= output. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Owner
|
This may take a while to review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Fixes #405
Association tables with a primary key are now generated as SQLModel link model classes and referenced via
Relationship(link_model=...), matching the SQLModel documentation. Link tables without a primary key still render as plain Table. A new nolinktables option restores the previous output.Checklist
If this is a user-facing code change, like a bugfix or a new feature, please ensure that
you've fulfilled the following conditions (where applicable):
tests/) which would fail without your patchCHANGES.rst).