- Notifications
You must be signed in to change notification settings - Fork 182
Description
Steps to reproduce
Originated from loopbackio/loopback-next#4474
To reproduce it, remove the special check for postgresql on this line, and run the tests.
You will see isActive
returns true when run the shared tests with postgresql.
The reason is explained in loopbackio/loopback-next#4474 (comment):
packages/repository
has a juggler and its loopback-connector as dep, and juggler's Transaction mixin is applied to its lb-connector's Transaction.
So tests in mysql creates transaction with the Transaction that has mixin's overriden prototype methods.
While for postgresql, create transaction
uses the Transaction in acceptance/repository-postgresql
's dependency, which doesn't have the juggler's Transaction mixin applied. And therefore won't delete the connection reference for tx
The transaction's design in this connector changes after PR #230, I couldn't recall what issue it fixed exactly, but now it looks like returning a new transaction instead of a connection causes inconsistency between postgresql and other connectors, which results in juggler's mixin functions like commit
are not applied on that transation's prototype.
Current Behavior
See ^
create transaction
uses the Transaction in acceptance/repository-postgresql
's dependency, which doesn't have the juggler's Transaction mixin applied. And therefore won't delete the connection reference for tx
Expected Behavior
Postgresql connector should have consistent behaviour as other connectors on the transaction:
beginTransaction
should return connection instead of creating a transaction then return it- The original issue fixed by Fix operations on ended transactions #230 should be revisited, and replaced with another solution that doesn't introduce the inconsistent behaviour.