-
Notifications
You must be signed in to change notification settings - Fork 279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: TransactionBuilder.setMode() #1274
Comments
Hey 👋 We're able to add things that are optional for existing drivers. e.g. savepoint methods in the upcoming I'm not sure about the naming of this method. PostgreSQL docs refer to them as "modes", together with isolation levels.
MySQL docs refer to them as "characteristics".
SQLite docs refer to them as "behaviors".
Also, putting all of these together in one method will be confusing for users: e.g. PostgreSQL has the It seems that, unlike with isolation levels, the specs here diverge more. |
How about Or what about just adding |
This is unintuitive. Naming has to be close to spec. |
PostgreSQL docs refer to them as "access modes":
MySQL docs also refer to them as "access modes":
This pushes us strongly towards setAccessMode(accessMode: 'read write' | 'read only') |
PostgreSQL's PostgresSQL docs also refer to them as just "properties"
This pushes us towards setBehavior(behavior: 'deferrable' | 'not deferrable' | 'deferred' | 'immediate' | 'exclusive') Which is not ideal - wish PostgreSQL (the popular one) had a proper name for this, but its the lesser evil. |
Some SQL dialects have different ways to start a transaction for write or read-only. I'm writing a driver for SQLite, which has
BEGIN DEFERRED
andBEGIN IMMEDIATE
. Postgresql and MySQL haveSTART TRANSACTION READ ONLY
andSTART TRANSACTION READ WRITE
. It would be great if an implementation ofDriver.beginTransaction()
could get enough information to choose among these variants.I'm suggesting a new method
TransactionBuilder.setMode(mode)
, where mode can be'read-only'|'read-write'
. This optional value would be passed to the driver in a newmode
property onTransactionSettings
.In SQLite, the value of using
BEGIN IMMEDIATE
for a write transaction is that potential deadlock will be detected by attempting to acquire an exclusive lock immediately. This would allow the driver to implement backoff and retry inbeginTransaction()
instead of requiring handling at the application level.Note that I'm only requesting a way for drivers to get this information, not necessarily for any currently provided drivers to add support.
Thanks for your consideration!
The text was updated successfully, but these errors were encountered: