-
-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Description
Description
Column defined with
ModTime int64 `gorm:"column:mod_time;not null;autoUpdateTime:nano;index:,composite:mod_time"`
is populated correctly with nano timestamps in sqlite3 but in mysql values are rounded to ms i.e. you get 1689751262515000000 instead of 1689751262515828345 in mysql column.
Workaround that works for us is to set datetimePrecision = 9 or force NowFunc i.e.
&gorm.Config{
NowFunc: func() time.Time {
return time.Now() // Here we use monotonic clock to avoid clock synchronization diffs see https://pkg.go.dev/time#hdr-Monotonic_Clocks
},
})
Adding ;precision:9 nor ;precision=9 field tag to ModTime column definition as above does not work.
Datetime precision logic should not be used probably for autoCreateTime nor autoUpdateTime columns because it defines time resolution on its own.
Metadata
Metadata
Assignees
Labels
No labels