Skip to content

@afterUpdate always says array/json field updated #5967

@zh99998

Description

@zh99998

Issue type:

[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

I have an entity with some fields of json object and array type. like:

  @Column({ type: 'jsonb', default: {} })
  data: object;
  @Column({ default: '{}', type: 'text', array: true)
  inventoryAvatars: string[];
  @Column({ default: '{}', type: 'text', array: true)
  inventoryEmoji: string[];

and a subscriber

@EventSubscriber()
export class UserSubscriber implements EntitySubscriberInterface<User> {
  listenTo() {
    return User;
  }
  afterUpdate(event: UpdateEvent<User>): Promise<any> | void {
    console.log(event.updatedColumns.map(x=>x.propertyName));
  }
}

now I found that after any changes made, all array/object type fields are in event.updatedColumns. even they are not modified.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions