8000 Making PSQLPy SQLAlchemy compatible · psqlpy-python/psqlpy@414f2ac · GitHub
[go: up one dir, main page]

Skip to content

Commit 414f2ac

Browse files
committed
Making PSQLPy SQLAlchemy compatible
1 parent 55a44e7 commit 414f2ac

File tree

17 files changed

+845
-1542
lines changed

17 files changed

+845
-1542
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ crate-type = ["cdylib"]
1010

1111
[dependencies]
1212
deadpool-postgres = { git = "https://github.com/chandr-andr/deadpool.git", branch = "psqlpy" }
13-
pyo3 = { version = "0.23.4", features = ["chrono", "experimental-async", "rust_decimal", "py-clone", "macros"] }
13+
pyo3 = { version = "0.23.4", features = ["chrono", "experimental-async", "rust_decimal", "py-clone", "macros", "multiple-pymethods"] }
1414
pyo3-async-runtimes = { git = "https://github.com/chandr-andr/pyo3-async-runtimes.git", branch = "psqlpy", features = [
1515
"tokio-runtime",
1616
] }

python/tests/test_transaction.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
IsolationLevel,
1010
ReadVariant,
1111
)
12+
from psqlpy._internal.exceptions import TransactionClosedError
1213
from psqlpy.exceptions import (
1314
InterfaceError,
14-
TransactionBeginError,
1515
TransactionExecuteError,
16-
TransactionSavepointError,
1716
)
1817

1918
from tests.helpers import count_rows_in_test_table
@@ -64,10 +63,10 @@ async def test_transaction_begin(
6463
connection = await psql_pool.connection()
6564
transaction = connection.transaction()
6665

67-
with pytest.raises(expected_exception=TransactionBeginError):
68-
await transaction.execute(
69-
f"SELECT * FROM {table_name}",
70-
)
66+
# with pytest.raises(expected_exception=TransactionBeginError):
67+
await transaction.execute(
68+
f"SELECT * FROM {table_name}",
69+
)
7170

7271
await transaction.begin()
7372

@@ -170,7 +169,7 @@ async def test_transaction_rollback(
170169

171170
await transaction.rollback()
172171

173-
with pytest.raises(expected_exception=TransactionBeginError):
172+
with pytest.raises(expected_exception=TransactionClosedError):
174173
await transaction.execute(
175174
f"SELECT * FROM {table_name} WHERE name = $1",
176175
parameters=[test_name],
@@ -198,9 +197,8 @@ async def test_transaction_release_savepoint(
198197
sp_name_2 = "sp2"
199198

200199
await transaction.create_savepoint(sp_name_1)
201-
202-
with pytest.raises(expected_exception=TransactionSavepointError):
203-
await transaction.create_savepoint(sp_name_1)
200+
# There is no problem in creating the same sp_name
201+
await transaction.create_savepoint(sp_name_1)
204202

205203
await transaction.create_savepoint(sp_name_2)
206204

0 commit comments

Comments
 (0)
0