summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-05-23 10:34:32 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-05-23 14:53:26 -0400
commitc0612f8166b7cd07895e7302bb59192abbb68c43 (patch)
treeab8e6c5948ef23008789a49aa6128c1a3e7c0517
parent853f726454cff2f34c010cbafacfec85f51f8eeb (diff)
downloadsqlalchemy-c0612f8166b7cd07895e7302bb59192abbb68c43.tar.gz
enable pg8000 for 1.29.1 and above
ROLLBACK TO SAVEPOINT is re-enabled in https://github.com/tlocke/pg8000/issues/111. we still have to add savepoint support to our fixture that deletes from tables without checking for them. this is inconvenient but not incorrect. Change-Id: I2f4a0a3e18db93c3e6794ade9b0fee33d2e4b7dc
-rw-r--r--lib/sqlalchemy/testing/fixtures.py10
-rw-r--r--setup.cfg2
-rw-r--r--test/engine/test_transaction.py10
3 files changed, 18 insertions, 4 deletions
diff --git a/lib/sqlalchemy/testing/fixtures.py b/lib/sqlalchemy/testing/fixtures.py
index d4e4d2dca..4b5366186 100644
--- a/lib/sqlalchemy/testing/fixtures.py
+++ b/lib/sqlalchemy/testing/fixtures.py
@@ -461,6 +461,10 @@ class TablesTest(TestBase):
elif self.run_create_tables == "each":
drop_all_tables_from_metadata(self._tables_metadata, self.bind)
+ savepoints = getattr(config.requirements, "savepoints", False)
+ if savepoints:
+ savepoints = savepoints.enabled
+
# no need to run deletes if tables are recreated on setup
if (
self.run_define_tables != "each"
@@ -478,7 +482,11 @@ class TablesTest(TestBase):
]
):
try:
- conn.execute(table.delete())
+ if savepoints:
+ with conn.begin_nested():
+ conn.execute(table.delete())
+ else:
+ conn.execute(table.delete())
except sa.exc.DBAPIError as ex:
print(
("Error emptying table %s: %r" % (table, ex)),
diff --git a/setup.cfg b/setup.cfg
index c49cb69ea..2a272e0ba 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -57,7 +57,7 @@ mariadb_connector =
oracle =
cx_oracle>=7
postgresql = psycopg2>=2.7
-postgresql_pg8000 = pg8000>=1.16.6,<1.29
+postgresql_pg8000 = pg8000>=1.16.6,!=1.29.0
postgresql_asyncpg =
%(asyncio)s
asyncpg
diff --git a/test/engine/test_transaction.py b/test/engine/test_transaction.py
index 696391512..fdaa80835 100644
--- a/test/engine/test_transaction.py
+++ b/test/engine/test_transaction.py
@@ -238,7 +238,10 @@ class TransactionTest(fixtures.TablesTest):
with testing.expect_warnings("nested transaction already"):
s1.rollback() # no error (though it warns)
- t1.commit() # no error
+ # this test was previously calling "commit", but note relies on
+ # buggy behavior in PostgreSQL as the transaction block is in fact
+ # aborted. pg8000 enforces this on the client as of 1.29
+ t1.rollback() # no error
@testing.requires.savepoints_w_release
def test_savepoint_release_fails_flat(self):
@@ -260,7 +263,10 @@ class TransactionTest(fixtures.TablesTest):
assert not s1.is_active
s1.rollback() # no error. prior to 1.4 this would try to rollback
- t1.commit() # no error
+ # this test was previously calling "commit", but note relies on
+ # buggy behavior in PostgreSQL as the transaction block is in fact
+ # aborted. pg8000 enforces this on the client as of 1.29
+ t1.rollback() # no error
@testing.requires.savepoints_w_release
def test_savepoint_release_fails_ctxmanager(self, local_connection):