Skip to content

Commit 0ab49ec

Browse files
authored
Update dependencies and address sqlalchemy-bind-manager breaking changes (#144)
Signed-off-by: Federico Busetti <[email protected]>
1 parent c32e9ee commit 0ab49ec

File tree

5 files changed

+48
-44
lines changed

5 files changed

+48
-44
lines changed

poetry.lock

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from pydantic import BaseModel
55
from pydantic_settings import BaseSettings, SettingsConfigDict
6-
from sqlalchemy_bind_manager import SQLAlchemyAsyncConfig
6+
from sqlalchemy_bind_manager import SQLAlchemyConfig
77

88
TYPE_ENVIRONMENT = Literal["local", "test", "staging", "production"]
99

@@ -49,8 +49,8 @@ class AppConfig(BaseSettings):
4949
CELERY: CeleryConfig = CeleryConfig()
5050
DEBUG: bool = False
5151
ENVIRONMENT: TYPE_ENVIRONMENT = "local"
52-
SQLALCHEMY_CONFIG: Dict[str, SQLAlchemyAsyncConfig] = dict(
53-
default=SQLAlchemyAsyncConfig(
52+
SQLALCHEMY_CONFIG: Dict[str, SQLAlchemyConfig] = dict(
53+
default=SQLAlchemyConfig(
5454
engine_url=f"sqlite+aiosqlite:///{Path(__file__).parent.parent.joinpath('sqlite.db')}",
5555
engine_options=dict(
5656
connect_args={
@@ -59,5 +59,6 @@ class AppConfig(BaseSettings):
5959
echo=False,
6060
future=True,
6161
),
62+
async_engine=True,
6263
),
6364
)

src/domains/books/_gateway_interfaces.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from collections.abc import Iterable, Mapping
2-
from typing import Any, List, Protocol, Tuple, Union
3-
4-
from sqlalchemy_bind_manager.repository import SortDirection
2+
from typing import Any, List, Literal, Protocol, Tuple, Union
53

64
from domains.books._models import BookModel
75
from domains.common.cloudevent_base import BaseEvent
@@ -13,7 +11,9 @@ async def save(self, book: BookModel) -> BookModel: ...
1311
async def find(
1412
self,
1513
search_params: Union[None, Mapping[str, Any]] = None,
16-
order_by: Union[None, Iterable[Union[str, Tuple[str, SortDirection]]]] = None,
14+
order_by: Union[
15+
None, Iterable[Union[str, Tuple[str, Literal["asc", "desc"]]]]
16+
] = None,
1717
) -> List[BookModel]: ...
1818

1919

tests/storage/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
import pytest
44
from bootstrap.storage.SQLAlchemy import init_tables
55
from sqlalchemy.orm import clear_mappers
6-
from sqlalchemy_bind_manager import SQLAlchemyAsyncConfig, SQLAlchemyBindManager
6+
from sqlalchemy_bind_manager import SQLAlchemyBindManager, SQLAlchemyConfig
77

88

99
@pytest.fixture(scope="function")
1010
async def test_sa_manager() -> AsyncIterator[SQLAlchemyBindManager]:
1111
clear_mappers()
1212

13-
db_config = SQLAlchemyAsyncConfig(
13+
db_config = SQLAlchemyConfig(
1414
engine_url="sqlite+aiosqlite://",
1515
engine_options=dict(connect_args={"check_same_thread": False}),
16+
async_engine=True,
1617
)
1718
sa_manager = SQLAlchemyBindManager(config=db_config)
1819
init_tables(sqlalchemy_manager=sa_manager)

tests/storage/test_sqlalchemy_init.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from bootstrap.storage import init_storage
66
from bootstrap.storage.SQLAlchemy import TABLE_INIT_REGISTRY, init_tables
7-
from sqlalchemy_bind_manager import SQLAlchemyAsyncConfig, SQLAlchemyBindManager
7+
from sqlalchemy_bind_manager import SQLAlchemyBindManager, SQLAlchemyConfig
88

99

1010
def test_init_tables_calls_only_supported_bind_initialisation():
@@ -13,15 +13,17 @@ def test_init_tables_calls_only_supported_bind_initialisation():
1313

1414
sa_manager = SQLAlchemyBindManager(
1515
config={
16-
"default": SQLAlchemyAsyncConfig(
16+
"default": SQLAlchemyConfig(
1717
engine_url=f"sqlite+aiosqlite:///{db1_path}",
1818
engine_options=dict(connect_args={"check_same_thread": False}),
1919
session_options=dict(expire_on_commit=False),
20+
async_engine=True,
2021
),
21-
"not_existing": SQLAlchemyAsyncConfig(
22+
"not_existing": SQLAlchemyConfig(
2223
engine_url=f"sqlite+aiosqlite:///{db2_path}",
2324
engine_options=dict(connect_args={"check_same_thread": False}),
2425
session_options=dict(expire_on_commit=False),
26+
async_engine=True,
2527
),
2628
}
2729
)

0 commit comments

Comments
 (0)