Replies: 4 comments 24 replies
-
I like the idea. Few comments:
Not sure how it would prevent "accidental" transactions and what they are.
That's a nice improvement indeed.
Yes, I can see that, provided we can have clear tutorials suggesting the pattern. There are also some modes of operation that are valid only within a transaction, like creating a cursor. If we implement this proposal, the One more idea: perhaps we can add a way to acquire a connection from the pool without |
Beta Was this translation helpful? Give feedback.
-
I'm not sure I like the idea of doing that by default. But can you elaborate a little on how you would do this? |
Beta Was this translation helpful? Give feedback.
-
One important note for the rust version: |
Beta Was this translation helpful? Give feedback.
-
We also should think how sub-transactions should be done:
I.e. I would temporary block respective methods in |
Beta Was this translation helpful? Give feedback.
-
@tailhook suggested in Slack:
I'd like to have queries executed on the transaction object itself rather than on connection:
Or
The reasons are:
Passing transaction to helper functions explicitly (rather than connection which might have active transaction or might have not) looks better
This prevents things accidentally get into transaction, if connection is any kind of global and any function can call it.
We're likely do that in Rust anyway, as we need to borrow a connection for the transaction.
This allows pool.transaction() directly rather than two layers of with.
Basically, there is no need to use connection in 99% apps, after this change, it's either pool.query() or transaction.query(). So we get rid of the pattern of acquiring a connection for a long time and holding it (for a duration of HTTP request for example).
(and if we're going to fix this we should also do "repeating a transaction" by default too)
Beta Was this translation helpful? Give feedback.
All reactions