-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Labels
Description
Issue description
Within a transaction, the { data } object provided should also be provided to the beforeTransactionCommit, afterTransactionCommit, etc subscribers
When calling method like insert, update, save and providing OrmOptions, for example:
const myEntity = new MyEntity({ id: 1, status 1 });
await manager.transaction(async (manager) => {
await queryRunner.insert(myEntity, { someData: true });
await queryRunner.update({ ...myEntity, status: 2 });
}); Expected Behaviour
This is what should be happening
/**
* Called after entity insert.
*/
afterInsert(event: InsertEvent<any>) {
console.log(`AFTER ENTITY INSERTED: `, event.queryRunner.data) // ✅
}
/**
* Called after entity update.
*/
afterUpdate(event: UpdateEvent<any>) {
console.log(`AFTER ENTITY UPDATED: `, event.queryRunner.data) // ✅
}
/**
* Called after transaction commit.
*/
afterTransactionCommit(event: TransactionCommitEvent) {
console.log(`AFTER TRANSACTION COMMITTED: `, event.queryRunner.data) // ✅
}Actual Behavior
This is what is happening
/**
* Called after entity insert.
*/
afterInsert(event: InsertEvent<any>) {
console.log(`AFTER ENTITY INSERTED: `, event.queryRunner.data) // ✅
}
/**
* Called after entity update.
*/
afterUpdate(event: UpdateEvent<any>) {
console.log(`AFTER ENTITY UPDATED: `, event.queryRunner.data) // ✅
}
/**
* Called after transaction commit.
*/
afterTransactionCommit(event: TransactionCommitEvent) {
console.log(`AFTER TRANSACTION COMMITTED: `, event.queryRunner.data) // ❌
}Steps to reproduce
Here's a PR with the test that shows the issue (if you remove the fix it'll fail)
https://github.com/typeorm/typeorm/pull/10151/files
My Environment
| Dependency | Version |
|---|---|
| Operating System | Mac/Linux |
| Node.js version | 18.15.0 |
| Typescript version | 5.0.4 |
| TypeORM version | 0.3.1.0 |
Additional Context
No response
Relevant Database Driver(s)
- aurora-mysql
- aurora-postgres
- better-sqlite3
- cockroachdb
- cordova
- expo
- mongodb
- mysql
- nativescript
- oracle
- postgres
- react-native
- sap
- spanner
- sqlite
- sqlite-abstract
- sqljs
- sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
Yes, I have the time, and I know how to start.