You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
queryRunner.clearDatabase() fails if trying to run inside a transaction.
Expected Behavior
It clears the database inside the transaction, then operations can be performed inside the transaction on a temporarily empty database, and that transaction can later be reverted
Actual Behavior
It throws TransactionAlreadyStartedError when trying to clearDatabase inside a transaction
// TransactionAlreadyStartedError: Transaction already started for the given connection, commit current transaction before starting a new one.
Steps to Reproduce
Connect to a databsae
Start Transaction
clearDatabase
It throws TransactionAlreadyStartedError
constconnection=awaitcreateConnection();constqueryRunner=connection.createQueryRunner();awaitqueryRunner.startTransaction();awaitqueryRunner.clearDatabase();// ^ This fails with `TransactionAlreadyStartedError`
My Environment
Dependency
Version
Operating System
macOS
Node.js version
16.13.1
Typescript version
4.5.4
TypeORM version
0.2.41
Additional Context
I want to clearDatabase inside a transaction, so I could get a temporary blank slate database, and then run migrations inside the same transaction, so I can determine what tables are missing after running all migrations regardless of, and without modifying the initial state of the database
Relevant Database Driver(s)
DB Type
Reproducible
aurora-data-api
no
aurora-data-api-pg
no
better-sqlite3
no
cockroachdb
no
cordova
no
expo
no
mongodb
no
mysql
no
nativescript
no
oracle
no
postgres
yes
react-native
no
sap
no
sqlite
no
sqlite-abstract
no
sqljs
no
sqlserver
no
Are you willing to resolve this issue by submitting a Pull Request?
✅ Yes, I have the time, and I know how to start.
✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
✖️ No, I don’t have the time, but I can support (using donations) development.
✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
The text was updated successfully, but these errors were encountered:
Issue Description
queryRunner.clearDatabase()
fails if trying to run inside a transaction.Expected Behavior
It clears the database inside the transaction, then operations can be performed inside the transaction on a temporarily empty database, and that transaction can later be reverted
Actual Behavior
It throws
TransactionAlreadyStartedError
when trying toclearDatabase
inside a transactionSteps to Reproduce
clearDatabase
TransactionAlreadyStartedError
My Environment
Additional Context
I want to
clearDatabase
inside a transaction, so I could get a temporary blank slate database, and then run migrations inside the same transaction, so I can determine what tables are missing after running all migrations regardless of, and without modifying the initial state of the databaseRelevant Database Driver(s)
aurora-data-api
aurora-data-api-pg
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: