]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
enable pg8000 for 1.29.1 and above
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 23 May 2022 14:34:32 +0000 (10:34 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 23 May 2022 18:53:26 +0000 (14:53 -0400)
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

lib/sqlalchemy/testing/fixtures.py
setup.cfg
test/engine/test_transaction.py

index d4e4d2dcad78b4c56212b56f7812ecc191dcfa90..4b53661860227eacea0630ddfc612e8f6a03beb4 100644 (file)
@@ -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)),
index c49cb69eaff9d1759b1cc48c3fe9ab2737cc9b6b..2a272e0ba49f9c3ba0bf1ce050284a037cc82c89 100644 (file)
--- 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
index 696391512eb13acdfdb407e123e63667f42c4063..fdaa808353e8f57d197721effba27a79b0aed6c2 100644 (file)
@@ -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):