feat(client): add transaction isolation level#878
Conversation
7c96c66 to
875bb3d
Compare
41b8671 to
d373351
Compare
e3f59f6 to
18b364c
Compare
| # TODO: remove after issue will be resolved | ||
| @pytest.mark.skipif(CURRENT_DATABASE in ['mysql', 'mariadb'], reason='https://github.com/prisma/prisma/issues/22890') | ||
| async def test_isolation_level( | ||
| client: Prisma, raw_queries: RawQueries, input_level: prisma.TransactionIsolationLevel, expected_level: str | ||
| ) -> None: | ||
| """A transaction isolation level is set correctly""" | ||
| async with client.tx(isolation_level=input_level) as tx: | ||
| results = await tx.query_raw(raw_queries.select_tx_isolation) | ||
|
|
||
| assert len(results) == 1 | ||
|
|
||
| row = results[0] | ||
| assert any(row) | ||
|
|
||
| level = next(iter(row.values())) | ||
| # The result can depends on the database, so we do upper() and replace() | ||
| level = str(level).upper().replace(' ', '_').replace('-', '_') | ||
| assert level == expected_level |
There was a problem hiding this comment.
@RobertCraigie I updated the tests and found here a bug in Prisma 😅
P.S. Look please at mypy (3.11) step why it doesn't pass.
There was a problem hiding this comment.
Oh wow, thanks for reporting that!
The mypy failure is unrelated to your PR, I'll look into fixing it.
There was a problem hiding this comment.
If you rebase against main, the mypy job should pass now.
There was a problem hiding this comment.
I'll update docs, then wait for a response from the Prisma team, and if bug will be confirmed, then PR will be ready to final review 🎉
There was a problem hiding this comment.
I'll update docs, then wait for a response from the Prisma team, and if bug will be confirmed, then PR will be ready to final review 🎉
Answer: prisma/prisma#22890 (comment)
There was a problem hiding this comment.
of course mysql doesn't even have a way to query that 🤦
I think it would be fine to just skip the tests for mysql if you haven't already.
There was a problem hiding this comment.
Sorry, I didn't know that...
It marked with skipif.
4991b5a to
ac76cbb
Compare
68fa3d7 to
ef194c1
Compare
69cc396 to
b31265b
Compare
This will be helpful for transaction isolation levels support #878
Change Summary
Add support for interactive transactions with an isolation level.
Closes #463.
Checklist
Agreement
By submitting this pull request, I confirm that you can use, modify, copy and redistribute this contribution, under the terms of your choice.