-
Notifications
You must be signed in to change notification settings - Fork 6
Description
I've noticed that when using the pooling option in node-orm2 that transactions don't work anymore. The source code of node-orm revealed that when pooling is used a new (or cached) connection is requested for every query executed (both for postgres and mysql). However, this also happens for queries inside a transaction. Therefore queries are executed using different connections and as a result these queries are no longer inside one transaction. Transactions should all be executed over one connection and a connection in a transaction should not be used for other queries as well.
One possible solution for this problem is that queries can be passed a connection/transaction object, such that users can manually group queries together in one transaction. Also, the connection used for a transaction should be removed from the pool as soon as the transaction starts and should be re-added as soon as the transaction is finished. This does require some modifications in the node-orm module however.
I'm happy to help fixing this problem, but since a solution to this problem requires modifying quite some code both in the node-orm module and most likely changes to the interface of either node-orm or this module it seemed best to me to discuss this first with you.