GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Fix connection leak when transaction commit/rollback raise an exception by masipcat · Pull Request #498 · encode/databases
This repository was archived by the owner on Aug 19, 2025. It is now read-only.
Conversation
|
|
Hi, thanks for the PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yeah no problem I'll add a test |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| async with Database(database_url) as database: | ||
| with pytest.raises(Exception) as excinfo: | ||
| async with database.connection() as connection: | ||
| await connection.execute( | ||
| """ | ||
| CREATE TABLE test (id integer PRIMARY KEY INITIALLY DEFERRED); | ||
| """ | ||
| ) | ||
| async with connection.transaction(): | ||
| await connection.execute("insert into test (id) values (1)") | ||
| await connection.execute("insert into test (id) values (1)") | ||
|
|
||
| # During transaction.commit() postgres will raise this exception: | ||
| # asyncpg.exceptions.UniqueViolationError: duplicate key value violates unique constraint "test_pkey" | ||
| # DETAIL: Key (id)=(1) already exists. | ||
| assert "unique constraint" in str(excinfo.value) | ||
| assert connection._connection_counter == 0 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@aminalaee I think this test it's only valid for postgresql. Is there a way to skip for other databases?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yeah sure,
databases/tests/test_databases.py
Line 482 in 6a52a4a
| async def test_transaction_commit_serializable(database_url): |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
At least 1 approving review is required to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.