Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 Add docs page for self-referential model #408

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

daniil-berg
Copy link
Contributor

@daniil-berg daniil-berg commented Aug 26, 2022

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 Villain class/model for demonstration in an attempt at honoring the Hero theme of the documentation. A villain can have a boss villain and villain minions.

Additional info

The new page also includes a brief explanation of the sa_relationship_kwargs parameter of the Relationship constructor, 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 for sa_-style parameters in SQLModel fields and relationships in the future.

Update (2022-08-02)

Rebased onto most recent version of the main branch (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).

@github-actions
Copy link

📝 Docs preview for commit e3dd424 at: https://6308770b7b8d7658d78c68dc--sqlmodel.netlify.app

@github-actions
Copy link

📝 Docs preview for commit 1860515 at: https://630879743f533d5c007b1ebc--sqlmodel.netlify.app

@codecov
Copy link

codecov bot commented Sep 2, 2022

Codecov Report

Merging #408 (51d7d80) into main (75ce455) will decrease coverage by 0.77%.
The diff coverage is 0.00%.

❗ Current head 51d7d80 differs from pull request most recent head 5b4c9e4. Consider uploading reports for the commit 5b4c9e4 to get more accurate results

@@            Coverage Diff             @@
##             main     #408      +/-   ##
==========================================
- Coverage   97.76%   96.99%   -0.78%     
==========================================
  Files         187      188       +1     
  Lines        6268     6318      +50     
==========================================
  Hits         6128     6128              
- Misses        140      190      +50     
Impacted Files Coverage Δ
docs_src/advanced/self_referential/tutorial001.py 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link

github-actions bot commented Sep 2, 2022

📝 Docs preview for commit 51d7d80 at: https://6311b4a3b6b5535c3dfe9f74--sqlmodel.netlify.app

@github-actions
Copy link

github-actions bot commented Sep 2, 2022

📝 Docs preview for commit 6e10a41 at: https://6311b96eef8da65cd180f3e6--sqlmodel.netlify.app

@github-actions
Copy link

github-actions bot commented Sep 2, 2022

📝 Docs preview for commit 5b4c9e4 at: https://6311ba9503310f5f48cdd4f0--sqlmodel.netlify.app

@github-actions
Copy link

📝 Docs preview for commit c702e78 at: https://639ce0eaa12b8e030c9de393--sqlmodel.netlify.app

@tiangolo tiangolo added the docs Improvements or additions to documentation label Oct 22, 2023
@jmehnle
Copy link

jmehnle commented Jan 7, 2025

@tiangolo, what's blocking this from being merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants