parent_children() now uses lazy='selectin'
This commit is contained in:
parent
da6c767698
commit
76921a2841
1 changed files with 5 additions and 3 deletions
|
|
@ -204,7 +204,7 @@ def age_pair(*, nullable: bool = False, **ka) -> tuple[Column, Column]:
|
||||||
return (date_col, acc_col)
|
return (date_col, acc_col)
|
||||||
|
|
||||||
|
|
||||||
def parent_children(keyword: str, /, **kwargs):
|
def parent_children(keyword: str, /, *, lazy: str = 'selectin', **kwargs):
|
||||||
"""
|
"""
|
||||||
Self-referential one-to-many relationship pair.
|
Self-referential one-to-many relationship pair.
|
||||||
Parent comes first, children come later.
|
Parent comes first, children come later.
|
||||||
|
|
@ -214,13 +214,15 @@ def parent_children(keyword: str, /, **kwargs):
|
||||||
|
|
||||||
Additional keyword arguments can be sourced with parent_ and child_ argument prefixes,
|
Additional keyword arguments can be sourced with parent_ and child_ argument prefixes,
|
||||||
obviously.
|
obviously.
|
||||||
|
|
||||||
|
CHANGED 0.5.0: the both relationship()s use lazy='selectin' attribute now by default.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
parent_kwargs = kwargs_prefix(kwargs, 'parent_')
|
parent_kwargs = kwargs_prefix(kwargs, 'parent_')
|
||||||
child_kwargs = kwargs_prefix(kwargs, 'child_')
|
child_kwargs = kwargs_prefix(kwargs, 'child_')
|
||||||
|
|
||||||
parent = Incomplete(relationship, Wanted(lambda o, n: o.__name__), back_populates=f'child_{keyword}s', **parent_kwargs)
|
parent = Incomplete(relationship, Wanted(lambda o, n: o.__name__), back_populates=f'child_{keyword}s', lazy=lazy, **parent_kwargs)
|
||||||
child = Incomplete(relationship, Wanted(lambda o, n: o.__name__), back_populates=f'parent_{keyword}', **child_kwargs)
|
child = Incomplete(relationship, Wanted(lambda o, n: o.__name__), back_populates=f'parent_{keyword}', lazy=lazy, **child_kwargs)
|
||||||
|
|
||||||
return parent, child
|
return parent, child
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue