Subscribers with both 'beforeUpdate' and 'afterUpdate' methods defined cause duplicate 'updatedColumn' entries #9948
Description
Issue description
Subscribers with both 'beforeUpdate' and 'afterUpdate' methods defined cause duplicate 'updatedColumn' entries
Expected Behavior
When I define an event subscriber with beforeUpdate
and afterUpdate
methods, and I use an entity manager to update a single column on a single entity, the afterUpdate
method on the subscriber should be called with an updatedColumns
argument which is an array of ColumnMetadata
that has a single entry, which describes the entity.
Actual Behavior
When I define an event subscriber with beforeUpdate
and afterUpdate
methods, and I use an entity manager to update a single field/column on a single entity, the afterUpdate
method on the subscriber is called with an updatedColumns
argument which has an array of ColumnMetadata
that with two entries, both of which describe the same column
Steps to reproduce
I've written a reproducable example using a NestJS template app here.
$ git clone --depth 1 git@github.com:powerbill/nest-typeorm-subsubscriber-sadness.git
$ cd nest-typeorm-subsubscriber-sadness
$ yarn install
$ yarn test
My Environment
Dependency | Version |
---|---|
Operating System | Darwin macbook14.local 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64 |
Node.js version | v16.16.0 |
Typescript version | 4.9.5 |
TypeORM version | 0.3.14 |
Additional Context
This happens even if the beforeUpdate
and afterUpdate
methods are defined on different objects which listenTo
the same entity type.
I've tested this against postgres and sqlite
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, but I don't know how to start. I would need guidance.