Skip to content

Commit

Permalink
fix: simplify string concatenation for error handling (#248)
Browse files Browse the repository at this point in the history
* fix: error message syntax.

* chore: bump version
  • Loading branch information
cofin authored Aug 22, 2024
1 parent fc1484b commit 4498095
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions advanced_alchemy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
2 changes: 1 addition & 1 deletion advanced_alchemy/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4498095

Please sign in to comment.