loopbackio/loopback-connector-postgresql

commit or rollback a transaction does not delete the connection's reference

jannyHou opened this issue · 3 comments

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 #230 should be revisited, and replaced with another solution that doesn't introduce the inconsistent behaviour.

Related Issues

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale commented

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

What is the status of the issue ?