From 4498095bd6bb55f8673419db08e0c36c09002ce1 Mon Sep 17 00:00:00 2001 From: Cody Fincher <204685+cofin@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:33:44 -0500 Subject: [PATCH] fix: simplify string concatenation for error handling (#248) * fix: error message syntax. * chore: bump version --- advanced_alchemy/base.py | 6 ++++++ advanced_alchemy/exceptions.py | 2 +- pyproject.toml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/advanced_alchemy/base.py b/advanced_alchemy/base.py index 6a65042d..9c497b23 100644 --- a/advanced_alchemy/base.py +++ b/advanced_alchemy/base.py @@ -358,6 +358,12 @@ class BigIntAuditBase(CommonTableAttributes, BigIntPrimaryKey, AuditColumns, Dec registry = orm_registry +class DefaultBase(CommonTableAttributes, DeclarativeBase): + """Base for all SQLAlchemy declarative models. No primary key is added""" + + registry = orm_registry + + class SQLQuery(BasicAttributes, DeclarativeBase): """Base for all SQLAlchemy custom mapped objects.""" diff --git a/advanced_alchemy/exceptions.py b/advanced_alchemy/exceptions.py index 6e395af1..8ba3b5b9 100644 --- a/advanced_alchemy/exceptions.py +++ b/advanced_alchemy/exceptions.py @@ -217,7 +217,7 @@ def wrap_sqlalchemy_exception( "check_constraint": (CHECK_CONSTRAINT_REGEXES.get(dialect_name, []), IntegrityError), "foreign_key": (FOREIGN_KEY_REGEXES.get(dialect_name, []), ForeignKeyError), } - detail = " - ".join(f"{exc_arg}!s" for exc_arg in exc.orig.args) if exc.orig.args else "" # type: ignore[union-attr] # pyright: ignore[reportArgumentType,reportOptionalMemberAccess] + detail = " - ".join(str(exc_arg) for exc_arg in exc.orig.args) if exc.orig.args else "" # type: ignore[union-attr] # pyright: ignore[reportArgumentType,reportOptionalMemberAccess] for key, (regexes, exception) in _keys_to_regex.items(): for regex in regexes: if (match := regex.findall(detail)) and match[0]: diff --git a/pyproject.toml b/pyproject.toml index c3eb7281..f0eec71e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ maintainers = [ name = "advanced_alchemy" readme = "README.md" requires-python = ">=3.8" -version = "0.19.1" +version = "0.19.2" [project.urls] Changelog = "https://docs.advanced-alchemy.litestar.dev/latest/changelog"