kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
10.47k stars 267 forks source link

Allow beginTransaction and rollbackTransaction calls. #956

Closed seivan closed 5 months ago

seivan commented 5 months ago

This is useful for unit tests that use the DB reference as a dependency injection on models. By calling beginTransaction on setups and rollbacks on teardown, we can simulate an isolated sandbox environment for the database.

This would be similar to ecto where the death(?) of the process indicate the rollback. Since we can't rely on the many test runners to manage that, the easiest would be if one could call the functions manually and making sure that db is in a transaction during each test.

igalklebanov commented 5 months ago

Hey 👋

Duplicate of #257.