-
-
Notifications
You must be signed in to change notification settings - Fork 645
Description
Motivation
We can't force a set of SQL queries to be executed on the same database connection, unless by doing a transaction, which is not what I want.
Additionally, this implies that a database connection used for a set of SQL queries may be used concurrently by another process, because DbConn is simply a pool, which acquires a connection on each query.
This is very unfortunate because it makes it impossible to ensure the lock/unlock of tables properly, for example.
It is indeed possible to do it ourselves, but it is very cumbersome and should be part of this library. Plus, we can't replicate the exact implementation of DbConn (e.g. with metrics etc).
Proposed Solutions
Make an additional type for acquired connections (not pools), that could be constructed from a new acquire method on the DbConn type. This new type would implement the traits ConnectionTrait and why not TransactionTrait.
Additional Information
This issue is related to #1457, which was converted into a discussion here: #1503, but nothing was done.