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"
]
):
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:
util.print_(
("Error emptying table %s: %r" % (table, ex)),
cx_oracle>=7,<8;python_version<"3"
cx_oracle>=7;python_version>="3"
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;python_version>="3"
# the case here due to the foreign key.
with expect_warnings(".*has no Python-side or server-side default.*"):
- with engine.begin() as conn:
+ with engine.connect() as conn:
+ conn.begin()
assert_raises(
(exc.IntegrityError, exc.ProgrammingError),
conn.execute,
with engine.begin() as conn:
conn.execute(table.insert(), {"id": 30, "data": "d1"})
- with engine.begin() as conn:
+ with engine.connect() as conn:
+ trans = conn.begin()
with expect_warnings(
".*has no Python-side or server-side default.*"
):
table.insert(),
{"data": "d2"},
)
+ trans.rollback()
- with engine.begin() as conn:
+ with engine.connect() as conn:
+ trans = conn.begin()
with expect_warnings(
".*has no Python-side or server-side default.*"
):
table.insert(),
[{"data": "d2"}, {"data": "d3"}],
)
+ trans.rollback()
- with engine.begin() as conn:
+ with engine.connect() as conn:
+ trans = conn.begin()
with expect_warnings(
".*has no Python-side or server-side default.*"
):
table.insert(),
{"data": "d2"},
)
+ trans.rollback()
- with engine.begin() as conn:
+ with engine.connect() as conn:
+ trans = conn.begin()
with expect_warnings(
".*has no Python-side or server-side default.*"
):
table.insert(),
[{"data": "d2"}, {"data": "d3"}],
)
+ trans.rollback()
with engine.begin() as conn:
conn.execute(
with engine.begin() as conn:
conn.execute(table.insert(), {"id": 30, "data": "d1"})
- with engine.begin() as conn:
+ with engine.connect() as conn:
+ trans = conn.begin()
with expect_warnings(
".*has no Python-side or server-side default.*"
):
{"data": "d2"},
)
- with engine.begin() as conn:
+ with engine.connect() as conn:
+ trans = conn.begin()
with expect_warnings(
".*has no Python-side or server-side default.*"
):
table.insert(),
[{"data": "d2"}, {"data": "d3"}],
)
+ trans.rollback()
with engine.begin() as conn:
conn.execute(
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):
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):