From 62956b05afe1098076d301e140bfa9e4f93f4063 Mon Sep 17 00:00:00 2001 From: Yusur Princeps Date: Sat, 23 Aug 2025 14:43:28 +0200 Subject: [PATCH 1/5] fix type return in declarative_base() --- src/suou/sqlalchemy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/suou/sqlalchemy.py b/src/suou/sqlalchemy.py index b16cae7..a1c2999 100644 --- a/src/suou/sqlalchemy.py +++ b/src/suou/sqlalchemy.py @@ -130,7 +130,8 @@ def bool_column(value: bool = False, nullable: bool = False, **kwargs): return Column(Boolean, server_default=def_val, nullable=nullable, **kwargs) -def declarative_base(domain_name: str, master_secret: bytes, metadata: dict | None = None, **kwargs) -> DeclarativeBase: + +def declarative_base(domain_name: str, master_secret: bytes, metadata: dict | None = None, **kwargs) -> type[DeclarativeBase]: """ Drop-in replacement for sqlalchemy.orm.declarative_base() taking in account requirements for SIQ generation (i.e. domain name). From ae789cf6411e764d3f4bda23657aaa40968e72a6 Mon Sep 17 00:00:00 2001 From: Yusur Princeps Date: Sat, 23 Aug 2025 14:54:58 +0200 Subject: [PATCH 2/5] update changelog, add lazy= to parent_children() --- CHANGELOG.md | 5 +++++ src/suou/sqlalchemy.py | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a52d1d..159089a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ + Added `addattr()`, `PrefixIdentifier()`, `mod_floor()`, `mod_ceil()` + 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 - Fixed a bug in `b64decode()` padding handling which made the function inconsistent and non injective. Now, leading `'A'` is NEVER stripped. diff --git a/src/suou/sqlalchemy.py b/src/suou/sqlalchemy.py index a1c2999..939a528 100644 --- a/src/suou/sqlalchemy.py +++ b/src/suou/sqlalchemy.py @@ -21,7 +21,7 @@ from functools import wraps from typing import Callable, Iterable, Never, TypeVar import warnings 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 .itertools import kwargs_prefix, makelist @@ -204,7 +204,7 @@ def age_pair(*, nullable: bool = False, **ka) -> tuple[Column, Column]: 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. Parent comes first, children come later. @@ -219,8 +219,8 @@ def parent_children(keyword: str, /, **kwargs): parent_kwargs = kwargs_prefix(kwargs, 'parent_') child_kwargs = kwargs_prefix(kwargs, 'child_') - parent = Incomplete(relationship, Wanted(lambda o, n: o.__name__), back_populates=f'child_{keyword}s', **parent_kwargs) - child = Incomplete(relationship, Wanted(lambda o, n: o.__name__), back_populates=f'parent_{keyword}', **child_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}', lazy=lazy, **child_kwargs) return parent, child From e3908c5795acb2b7b29fb3db80d16bcc27af823c Mon Sep 17 00:00:00 2001 From: Yusur Princeps Date: Sat, 23 Aug 2025 15:00:28 +0200 Subject: [PATCH 3/5] version advance --- src/suou/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/suou/__init__.py b/src/suou/__init__.py index 98834c2..a49eabd 100644 --- a/src/suou/__init__.py +++ b/src/suou/__init__.py @@ -29,7 +29,7 @@ from .snowflake import Snowflake, SnowflakeGen from .lex import symbol_table, lex, ilex from .strtools import PrefixIdentifier -__version__ = "0.4.0" +__version__ = "0.4.1" __all__ = ( 'ConfigOptions', 'ConfigParserConfigSource', 'ConfigSource', 'ConfigValue', From d91266b564df5b26af074824ade24fd16b1d15f9 Mon Sep 17 00:00:00 2001 From: Yusur Princeps Date: Sat, 23 Aug 2025 15:01:51 +0200 Subject: [PATCH 4/5] update changelog --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 159089a..ba0abfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.4.1 + +- Fixed return types for `.sqlalchemy` module. +- `sqlalchemy.parent_children()` now takes a `lazy` parameter. Backported from 0.5.1. + ## 0.4.0 + `pydantic` is now a hard dependency @@ -19,7 +24,7 @@ ## 0.3.8 - Fixed return types for `.sqlalchemy` module. -- `sqlalchemy.parent_children()` now takes a `lazy` parameter. Backported from 0.5.0. +- `sqlalchemy.parent_children()` now takes a `lazy` parameter. Backported from 0.5.1. ## 0.3.7 From bbac0423190565c1a0391c0216b1c11faac5b769 Mon Sep 17 00:00:00 2001 From: Yusur Princeps Date: Sat, 23 Aug 2025 15:13:32 +0200 Subject: [PATCH 5/5] lazy= is keyword-only in 0.5.0 --- CHANGELOG.md | 4 ++-- src/suou/sqlalchemy.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba0abfb..eaee5ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 0.4.1 - Fixed return types for `.sqlalchemy` module. -- `sqlalchemy.parent_children()` now takes a `lazy` parameter. Backported from 0.5.1. +- `sqlalchemy.parent_children()` now takes a `lazy` parameter. Backported from 0.5.0. ## 0.4.0 @@ -24,7 +24,7 @@ ## 0.3.8 - Fixed return types for `.sqlalchemy` module. -- `sqlalchemy.parent_children()` now takes a `lazy` parameter. Backported from 0.5.1. +- `sqlalchemy.parent_children()` now takes a `lazy` parameter. Backported from 0.5.0. ## 0.3.7 diff --git a/src/suou/sqlalchemy.py b/src/suou/sqlalchemy.py index 939a528..4c1ecd2 100644 --- a/src/suou/sqlalchemy.py +++ b/src/suou/sqlalchemy.py @@ -204,7 +204,7 @@ def age_pair(*, nullable: bool = False, **ka) -> tuple[Column, Column]: return (date_col, acc_col) -def parent_children(keyword: str, /, lazy='selectin', **kwargs) -> tuple[Incomplete[Relationship], Incomplete[Relationship]]: +def parent_children(keyword: str, /, *, lazy='selectin', **kwargs) -> tuple[Incomplete[Relationship], Incomplete[Relationship]]: """ Self-referential one-to-many relationship pair. Parent comes first, children come later.