Skip to content

@UpdateDateColumn.onupdate should work in all DBs #7347

Closed as not planned
Closed as not planned

Description

@intervalia

Issue Description

According to this page:
https://typeorm.delightful.studio/interfaces/_decorator_options_columnoptions_.columnoptions.html#onupdate

@UpdateDateColumn.onupdate currently only works in MySql. This should work in all Sql type of databases.

In MSSQL this is simply the inclusion of a single trigger:

Expected Behavior

This info in the entity.ts file

  @UpdateDateColumn({ nullable: false, default: () => 'GETUTCDATE()', onUpdate: 'GETUTCDATE()' })
  updatedAt: Date;

Should generate this SQL for MSSQL:

CREATE TRIGGER [xmlAuth_UpdateDate] ON [tableName] AFTER UPDATE AS UPDATE [tableName] SET updatedAt = GETUTCDATE() WHERE id in (SELECT DISTINCT FROM INSERTED);

Relevant 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?

  • 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, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.

Activity

  1. intervalia commented on Oct 13, 2023

    @intervalia
    Author

    FYI: I am no longer on the project that had this issue and have no way of validating if this is working or not. I still think it would be a good feature. Others will have to validate if it works.

  2. github-actions commented on Sep 18, 2025

    @github-actions

    TypeORM has returned to active development after recently transitioning to new leadership (see related announcement).

    As part of the new team's efforts to prioritise work on the project moving forward, it is necessary to clean up the backlog of stale issues.

    🧹 This issue is being automatically closed because it has had no activity in the last 6 months.
    If you believe this issue is still relevant, feel free to comment below and the maintainers may reopen it. Thank you for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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