go-gorm / gorm

The fantastic ORM library for Golang, aims to be developer friendly

Home Page:https://gorm.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

db.Save updates CreatedAt with a zero value.

szerr opened this issue · comments

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?

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