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

db.Save updates CreatedAt with a zero value. #7072

Closed
szerr opened this issue Jun 19, 2024 · 1 comment
Closed

db.Save updates CreatedAt with a zero value. #7072

szerr opened this issue Jun 19, 2024 · 1 comment
Assignees
Labels
type:with reproduction steps with reproduction steps

Comments

@szerr
Copy link

szerr commented Jun 19, 2024

GORM Playground Link

go-gorm/playground#742

Description

db.Save updates CreatedAt with a zero value. Then throws an error. Gorm should automatically handle CreatedAt and ignore zero values, right?

db.Create sets UpdatedAt to the current time, shouldn't it be null?

@github-actions github-actions bot added the type:with reproduction steps with reproduction steps label Jun 19, 2024
@jinzhu
Copy link
Member

jinzhu commented Jun 19, 2024

Create will fill the created_at field if it is empty, but Save will not do so with a blank primary key.

@jinzhu jinzhu closed this as completed Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:with reproduction steps with reproduction steps
Projects
None yet
Development

No branches or pull requests

2 participants