Skip to content

Commit b399813

Browse files
committed
Fix include and highlight intervals 2
1 parent aac3497 commit b399813

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/advanced/self-referential.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ To allow more fine-grained control over it, the `Relationship` constructor allow
1616

1717
Since SQLAlchemy relationships provide the [`remote_side`](https://docs.sqlalchemy.org/en/20/orm/relationship_api.html#sqlalchemy.orm.relationship.params.remote_side){.external-link target=_blank} parameter for just such an occasion, we can leverage that directly to construct the self-referential pattern with minimal code.
1818

19-
{* ./docs_src/advanced/self_referential/tutorial001.py ln[6:17] hl[16] *}
19+
{* ./docs_src/advanced/self_referential/tutorial001.py ln[6:18] hl[16] *}
2020

2121
Using the `sa_relationship_kwargs` parameter, we pass the keyword-argument `remote_side='Villain.id'` to the underlying relationship property.
2222

@@ -42,17 +42,17 @@ Finally, as with regular (i.e. non-self-referential) foreign key relationships,
4242

4343
Now let us see how we can create villains with a boss:
4444

45-
{* ./docs_src/advanced/self_referential/tutorial001.py ln[30:49] hl[34:35] *}
45+
{* ./docs_src/advanced/self_referential/tutorial001.py ln[31:50] hl[34:35] *}
4646

4747
Just as with regular relationships, we can simply pass our boss villain as an argument to the constructor with `boss=thinnus`.
4848

4949
If we only learn that a villain actually had a secret boss after we have already created him, we can just as easily assign him that boss retroactively:
5050

51-
{* ./docs_src/advanced/self_referential/tutorial001.py ln[30:31,51:55] hl[52] *}
51+
{* ./docs_src/advanced/self_referential/tutorial001.py ln[31:32,52:56] hl[52] *}
5252

5353
And if we want to add minions to a boss after the fact, this is as easy as adding items to a Python list (because that's all it is 🤓):
5454

55-
{* ./docs_src/advanced/self_referential/tutorial001.py ln[30:31,57:68] hl[61] *}
55+
{* ./docs_src/advanced/self_referential/tutorial001.py ln[31:32,58:69] hl[61] *}
5656

5757
Since our relationships work both ways, we don't even need to add all our `clone_bot_`s to the session individually. Instead we can simply add `ultra_bot` once again and commit the changes. We do need to refresh them all individually though, if we want to get their updated attributes.
5858

0 commit comments

Comments
 (0)