Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CreateDateColumn and UpdateDateColumn error #1172

Closed
aspandolfi opened this issue Nov 12, 2017 · 3 comments
Closed

CreateDateColumn and UpdateDateColumn error #1172

aspandolfi opened this issue Nov 12, 2017 · 3 comments

Comments

@aspandolfi
Copy link

CreateDateColumn and UpdateDateColumn are not working in MySQL. The syntax when the tabela is creating is not correct. Therefore, MySQL throws exception.

@pleerock
Copy link
Member

can you show me error you have and code you are running? Also mysql version. There are tests which completely cover this functionality and it cannot be broken.

@gaurav112
Copy link

gaurav112 commented Mar 15, 2018

I got the same issue

Mysql version: 5.5.59-0ubuntu0.14.04.1 - (Ubuntu)

@PrimaryGeneratedColumn()
id: number;

@ManyToOne(type => User)
sender: number;

@ManyToOne(type => Chat, chat => chat.messages)
chat: Chat;

@Column('varchar')
type: string;

@Column('text')
message: string;

@CreateDateColumn()
created_at: Date;

@UpdateDateColumn()
updated_at: Date;

this is the sql it generated

CREATE TABLE chat_messages (id int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, type varchar(255) NOT NULL, message text NOT NULL, created_at datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), updated_at datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), senderId int(11), chatId int(11)) ENGINE=InnoDB

the error it generated was

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): QueryFailedError: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), `updated_at` datetime(6) NOT NULL DEF' at line 1

@pleerock
Copy link
Member

duplicate of #609

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

No branches or pull requests

4 participants