-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
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:
[ ] latest
[ ] @next
[x] 0.2.17
Steps to reproduce or a small repository showing the problem:
I was renaming a createdAt column created by @CreateDateColumn() from created_at to createdAt using this migration.
await queryRunner.renameColumn('some_entity', 'created_at', 'createdAt');This resulted in the following SQL query and error:
ALTER TABLE `some_entity` CHANGE `created_at` `createdAt` datetime(6) NOT NULL DEFAULT 'current_timestamp(6)'QueryFailedError: ER_TRUNCATED_WRONG_VALUE: Incorrect datetime value: 'current_timestamp(6)' for column ``.``.`createdAt` at row 1
I think that TypeORM is reading the default value and using it when renaming the column, but not understanding that the current_timestamp(6) coming from the database is not a string but TypeORM is passing a string back to the database.
This happens no matter what form of renameColumn or changeColumn I use since renameColumn just defers to changeColumn and changeColumn decides whether to change or rename based on whether the TableColumn data you pass in is different.