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

Invalid default value for 'updated_at' #994

Closed
zrz4066 opened this issue Aug 25, 2022 · 4 comments
Closed

Invalid default value for 'updated_at' #994

zrz4066 opened this issue Aug 25, 2022 · 4 comments

Comments

@zrz4066
Copy link

zrz4066 commented Aug 25, 2022

If I use ”.col(ColumnDef::new(User::Created_at).date_time().not_null()) ”,It will work。it failed when Change to ".col(ColumnDef::new(User::Created_at).timestamp_with_time_zone().not_null())", error is "Exec("error returned from database: 1067 (42000): Invalid default value for 'updated_at'")"

1661439352673

@billy1624
Copy link
Member

Hey @zrz4066, my wild guess is that you're using MySQL as the database?

Similar issue has been discussed at #854.

My suggestion for you. Try adding a .extra("DEFAULT CURRENT_TIMESTAMP()") on both timestamp column. It's a workaround before this, SeaQL/sea-query#428, lands.

@tyt2y3
Copy link
Member

tyt2y3 commented Sep 13, 2022

Close as duplicate

@tyt2y3 tyt2y3 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2022
@dreamerlzl
Copy link

Could we make this obvious somewhere in the tutorial or docs?
Also, it shall be .extra("default CURRENT_TIMESTAMP".to_string())

@billy1624
Copy link
Member

Hey @dreamerlzl, the workaround isn't need anymore after next SeaORM & SeaQuery release.
https://github.com/SeaQL/sea-query/blob/a7f2defac169c93f9b6a059264d9ba52aebb9b43/src/table/column.rs#L154-L161

@billy1624 billy1624 moved this from Triage to Done in SeaQL Dev Tracker Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

4 participants