Skip to content

Commit

Permalink
fix: moved function breaks Litestar imports. (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterschutt committed Mar 25, 2024
1 parent 0843eef commit bd4cb2c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions advanced_alchemy/repository/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

from typing import TYPE_CHECKING, Any, cast

from advanced_alchemy.exceptions import wrap_sqlalchemy_exception as _wrap_sqlalchemy_exception

if TYPE_CHECKING:
from sqlalchemy.orm import InstrumentedAttribute

from advanced_alchemy.base import ModelProtocol
from advanced_alchemy.repository.typing import ModelT

# NOTE: For backward compatibility with Litestar - this is imported from here within the litestar codebase.
wrap_sqlalchemy_exception = _wrap_sqlalchemy_exception


def get_instrumented_attr(model: type[ModelProtocol], key: str | InstrumentedAttribute) -> InstrumentedAttribute:
if isinstance(key, str):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ruff: noqa: F401


def test_repository_re_exports() -> None:
from litestar.contrib.sqlalchemy import types
from litestar.contrib.sqlalchemy.repository import (
SQLAlchemyAsyncRepository,
SQLAlchemySyncRepository,
wrap_sqlalchemy_exception,
)

0 comments on commit bd4cb2c

Please sign in to comment.