Skip to content

Transaction SAVEPOINT support #12898

@revmischa

Description

@revmischa

Problem

I would like to use the SQL SAVEPOINT (nested transaction) feature for nesting transactions.

My use case: running integration tests inside of isolated transactions. More details in prisma/web#6604

I would like to temporarily replace BEGIN statements with SAVEPOINT statements for code executed in my test. The idea is that I want to wrap each test inside its own transaction so it's isolated and doesn't see data from any other tests running at the same time, and issue a ROLLBACK at the end so the test never actually commits anything to the DB.

To make this work I need to disable any code running inside the test from beginning a new transaction, instead creating a savepoint. More details can be seen in prisma/web#6604.

Suggested solution

Something like SQLAlchemy perhaps: https://docs.sqlalchemy.org/en/14/orm/session_transaction.html#using-savepoint

Alternatives

Currently I have to run integration tests one by one and truncate every table at the end of each test. This is horribly slow and inefficient and prevents me from running my tests in parallel.

Additional context

prisma/web#6604

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions