Skip to content

Commit f4d1361

Browse files
committed
Invert location of more explanatory test transaction comment
The sync and async `test_tx` fixtures have been inverted as to their position in the file, so "see above" didn't make sense anymore. Here, move the longer, more explanatory comment up to async `test_tx` since it's not nearer to the top of the file.
1 parent e90ec18 commit f4d1361

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tests/driver/riversqlalchemy/sqlalchemy_driver_test.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,16 @@ async def test_tx(
3636
async with engine_async.connect() as conn_tx:
3737
# Force SQLAlchemy to open a transaction.
3838
#
39-
# See explanatory comment in `test_tx()` above.
39+
# SQLAlchemy seems to be designed to operate as surprisingly as
40+
# possible. Invoking `begin()` doesn't actually start a transaction.
41+
# Instead, it only does so lazily when a command is first issued. This
42+
# can be a big problem for our internal code, because when it wants to
43+
# start a transaction of its own to do say, a uniqueness check, unless
44+
# another SQL command has already executed it'll accidentally start a
45+
# top-level transaction instead of one in a test transaction that'll be
46+
# rolled back, and cause our tests to commit test jobs. So to work
47+
# around that, we make sure to fire an initial command, thereby forcing
48+
# a transaction to begin. Absolutely terrible design.
4049
await conn_tx.execute(sqlalchemy.text("SELECT 1"))
4150

4251
yield conn_tx
@@ -221,16 +230,7 @@ def test_tx(engine: sqlalchemy.Engine) -> Iterator[sqlalchemy.Connection]:
221230
with engine.connect() as conn_tx:
222231
# Force SQLAlchemy to open a transaction.
223232
#
224-
# SQLAlchemy seems to be designed to operate as surprisingly as
225-
# possible. Invoking `begin()` doesn't actually start a transaction.
226-
# Instead, it only does so lazily when a command is first issued. This
227-
# can be a big problem for our internal code, because when it wants to
228-
# start a transaction of its own to do say, a uniqueness check, unless
229-
# another SQL command has already executed it'll accidentally start a
230-
# top-level transaction instead of one in a test transaction that'll be
231-
# rolled back, and cause our tests to commit test jobs. So to work
232-
# around that, we make sure to fire an initial command, thereby forcing
233-
# a transaction to begin. Absolutely terrible design.
233+
# See explanatory comment in `test_tx()` above.
234234
conn_tx.execute(sqlalchemy.text("SELECT 1"))
235235

236236
yield conn_tx

0 commit comments

Comments
 (0)