Skip to content

Error in Mysql query changing column name for @UpdateDateColumn #4281

@tzahush

Description

@tzahush

Issue type:

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

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[X] mysql / mariadb
[ ] oracle
[ ] 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:

When changing the column name in the database for an @UpdateDateColumn, it would create the following query:

ALTER TABLE *** CHANGE updated_at updated_at2 datetime(6) NOT NULL DEFAULT 'CURRENT_TIMESTAMP(6)'

But there is a fault in the query for mysql, the 'CURRENT_TIMESTAMP(6)' should be without brackets, like so:
ALTER TABLE *** CHANGE updated_at updated_at2 datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)

Otherwise the following error rises:
ALTER TABLE *** CHANGE updated_at updated_at2 datetime(6) NOT NULL DEFAULT 'CURRENT_TIMESTAMP(6)' Error Code: 1067. Invalid default value for 'updated_at2'

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