Skip to content

Releases: krylosov-aa/context-async-sqlalchemy

2.1.9

Choose a tag to compare

@krylosov-aa krylosov-aa released this 14 Jun 09:51

before_commit callback

All middlewares accept an optional before_commit parameter — an async callable that is invoked
right before each session with an open transaction is committed.

BeforeCommitCallback = Callable[[AsyncSession], Coroutine[Any, Any, None]]

The callback receives the AsyncSession that is about to be committed, so you can inspect its
state and perform side effects such as recording audit
data or capturing a WAL LSN.

async def my_before_commit(session: AsyncSession) -> None:
    # called once per session, just before commit
    ...

add_fastapi_http_db_session_middleware(app, before_commit=my_before_commit)

The callback is not called when a session is rolled back.

2.1.8

Choose a tag to compare

@krylosov-aa krylosov-aa released this 31 May 15:30
  • New linters have been introduced and checks in existing ones have been strengthened
  • Minor improvements in the tests

2.1.7

Choose a tag to compare

@krylosov-aa krylosov-aa released this 14 May 19:30
  • Fixed a potential race in session_maker
  • Fixed the run_in_new_ctx function. Isolation was working only incidentally via the Task that asyncio.gather wraps each call in

2.1.6

Choose a tag to compare

@krylosov-aa krylosov-aa released this 08 Dec 15:48

add py.typed

2.1.5

Choose a tag to compare

@krylosov-aa krylosov-aa released this 30 Nov 05:54

small fix in is_context_initiated, pop_db_session_from_context, get_db_session_from_context

2.1.4

Choose a tag to compare

@krylosov-aa krylosov-aa released this 28 Nov 22:37

atomic_db_session

There are several options that define how the function will handle
an already open transaction.
current_transaction:
"commit" - commits the open transaction and starts a new one
"rollback" - rolls back the open transaction and starts a new one
"append" - continues using the current transaction and commits it
"raise" - raises an InvalidRequestError

set_test_context

Use auto_close=False if you’re using a test session and transaction
that you close manually elsewhere in your code.

Use auto_close=True if, for example, you want to call a
function in a test that uses a context bypassing the
middleware, and you want all sessions to be closed automatically.

2.0.4

Choose a tag to compare

@krylosov-aa krylosov-aa released this 28 Nov 08:06

2.0.3

Choose a tag to compare

@krylosov-aa krylosov-aa released this 23 Nov 21:24

I removed modules from the init that not everyone needs

2.0.2

Choose a tag to compare

@krylosov-aa krylosov-aa released this 22 Nov 20:53

only doc fixes

2.0.0

Choose a tag to compare

@krylosov-aa krylosov-aa released this 21 Nov 22:49
1102691

lots of improvements