📝 Add docs page for self-referential model#408
Open
daniil-berg wants to merge 18 commits intofastapi:mainfrom
Open
📝 Add docs page for self-referential model#408daniil-berg wants to merge 18 commits intofastapi:mainfrom
daniil-berg wants to merge 18 commits intofastapi:mainfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
@tiangolo, what's blocking this from being merged? |
|
This is some really helpful documentation. @svlandeg anything we can do to get this merged? |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
YuriiMotov
reviewed
Aug 25, 2025
Member
YuriiMotov
left a comment
There was a problem hiding this comment.
@daniil-berg, thanks for working on this!
Great job!
I suggested a few minor improvements. Could you please take a look?
Also, we should probably create a group in Advanced (e.g. "Advanced Relationships") for other relationships-related sections such as #815
This comment was marked as outdated.
This comment was marked as outdated.
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
This comment was marked as outdated.
This comment was marked as outdated.
Contributor
📝 Docs previewLast commit 53809d1 at: https://fef55e49.sqlmodel.pages.dev Modified Pages |
svlandeg
reviewed
Oct 21, 2025
Member
svlandeg
left a comment
There was a problem hiding this comment.
I didn't review in detail (as Yurii already did 🙌), but just a few small nitpicks 😇
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
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.
Purpose
Adds a new page explaining how to construct a self-referential/recursive relationship with SQLModel to the Advanced User Guide section of the documentation. This is arguably a fairly common use case that has been asked about and discussed in issue #127 already.
Code
The example code uses a
Villainclass/model for demonstration in an attempt at honoring theHerotheme of the documentation. A villain can have abossvillain and villainminions.Additional info
The new page also includes a brief explanation of the
sa_relationship_kwargsparameter of theRelationshipconstructor, since that is essential for defining the desired relationship. Depending on how @tiangolo wants to structure the rest of the advanced guide, this section may either need to be expanded or instead abbreviated to a short mention and link to a dedicated section forsa_-style parameters in SQLModel fields and relationships in the future.Update (2022-08-02)
Rebased onto most recent version of the
mainbranch (0.0.8 release, 75ce455).Then rebased again, after adding tests to cover the new documentation example code. Coverage of the added code should now be at 100% (see latest codecov checks).