update changelog, add lazy= to parent_children()
This commit is contained in:
parent
62956b05af
commit
ae789cf641
2 changed files with 9 additions and 4 deletions
|
|
@ -16,6 +16,11 @@
|
||||||
+ Added `addattr()`, `PrefixIdentifier()`, `mod_floor()`, `mod_ceil()`
|
+ Added `addattr()`, `PrefixIdentifier()`, `mod_floor()`, `mod_ceil()`
|
||||||
+ First version to have unit tests! (Coverage is not yet complete)
|
+ First version to have unit tests! (Coverage is not yet complete)
|
||||||
|
|
||||||
|
## 0.3.8
|
||||||
|
|
||||||
|
- Fixed return types for `.sqlalchemy` module.
|
||||||
|
- `sqlalchemy.parent_children()` now takes a `lazy` parameter. Backported from 0.5.0.
|
||||||
|
|
||||||
## 0.3.7
|
## 0.3.7
|
||||||
|
|
||||||
- Fixed a bug in `b64decode()` padding handling which made the function inconsistent and non injective. Now, leading `'A'` is NEVER stripped.
|
- Fixed a bug in `b64decode()` padding handling which made the function inconsistent and non injective. Now, leading `'A'` is NEVER stripped.
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ from functools import wraps
|
||||||
from typing import Callable, Iterable, Never, TypeVar
|
from typing import Callable, Iterable, Never, TypeVar
|
||||||
import warnings
|
import warnings
|
||||||
from sqlalchemy import BigInteger, Boolean, CheckConstraint, Date, Dialect, ForeignKey, LargeBinary, Column, MetaData, SmallInteger, String, create_engine, select, text
|
from sqlalchemy import BigInteger, Boolean, CheckConstraint, Date, Dialect, ForeignKey, LargeBinary, Column, MetaData, SmallInteger, String, create_engine, select, text
|
||||||
from sqlalchemy.orm import DeclarativeBase, Session, declarative_base as _declarative_base, relationship
|
from sqlalchemy.orm import DeclarativeBase, Relationship, Session, declarative_base as _declarative_base, relationship
|
||||||
|
|
||||||
from .snowflake import SnowflakeGen
|
from .snowflake import SnowflakeGen
|
||||||
from .itertools import kwargs_prefix, makelist
|
from .itertools import kwargs_prefix, makelist
|
||||||
|
|
@ -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='selectin', **kwargs) -> tuple[Incomplete[Relationship], Incomplete[Relationship]]:
|
||||||
"""
|
"""
|
||||||
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.
|
||||||
|
|
@ -219,8 +219,8 @@ def parent_children(keyword: str, /, **kwargs):
|
||||||
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