mirror of https://github.com/go-gorm/gorm.git
chore: UnixNano convert to UnixMilli (#6907)
This commit is contained in:
parent
281f3e369a
commit
ab89d54d87
|
@ -351,7 +351,7 @@ func ConvertToCreateValues(stmt *gorm.Statement) (values clause.Values) {
|
||||||
case schema.UnixNanosecond:
|
case schema.UnixNanosecond:
|
||||||
assignment.Value = curTime.UnixNano()
|
assignment.Value = curTime.UnixNano()
|
||||||
case schema.UnixMillisecond:
|
case schema.UnixMillisecond:
|
||||||
assignment.Value = curTime.UnixNano() / 1e6
|
assignment.Value = curTime.UnixMilli()
|
||||||
case schema.UnixSecond:
|
case schema.UnixSecond:
|
||||||
assignment.Value = curTime.Unix()
|
assignment.Value = curTime.Unix()
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,7 +234,7 @@ func ConvertToAssignments(stmt *gorm.Statement) (set clause.Set) {
|
||||||
if field.AutoUpdateTime == schema.UnixNanosecond {
|
if field.AutoUpdateTime == schema.UnixNanosecond {
|
||||||
set = append(set, clause.Assignment{Column: clause.Column{Name: field.DBName}, Value: now.UnixNano()})
|
set = append(set, clause.Assignment{Column: clause.Column{Name: field.DBName}, Value: now.UnixNano()})
|
||||||
} else if field.AutoUpdateTime == schema.UnixMillisecond {
|
} else if field.AutoUpdateTime == schema.UnixMillisecond {
|
||||||
set = append(set, clause.Assignment{Column: clause.Column{Name: field.DBName}, Value: now.UnixNano() / 1e6})
|
set = append(set, clause.Assignment{Column: clause.Column{Name: field.DBName}, Value: now.UnixMilli()})
|
||||||
} else if field.AutoUpdateTime == schema.UnixSecond {
|
} else if field.AutoUpdateTime == schema.UnixSecond {
|
||||||
set = append(set, clause.Assignment{Column: clause.Column{Name: field.DBName}, Value: now.Unix()})
|
set = append(set, clause.Assignment{Column: clause.Column{Name: field.DBName}, Value: now.Unix()})
|
||||||
} else {
|
} else {
|
||||||
|
@ -268,7 +268,7 @@ func ConvertToAssignments(stmt *gorm.Statement) (set clause.Set) {
|
||||||
if field.AutoUpdateTime == schema.UnixNanosecond {
|
if field.AutoUpdateTime == schema.UnixNanosecond {
|
||||||
value = stmt.DB.NowFunc().UnixNano()
|
value = stmt.DB.NowFunc().UnixNano()
|
||||||
} else if field.AutoUpdateTime == schema.UnixMillisecond {
|
} else if field.AutoUpdateTime == schema.UnixMillisecond {
|
||||||
value = stmt.DB.NowFunc().UnixNano() / 1e6
|
value = stmt.DB.NowFunc().UnixMilli()
|
||||||
} else if field.AutoUpdateTime == schema.UnixSecond {
|
} else if field.AutoUpdateTime == schema.UnixSecond {
|
||||||
value = stmt.DB.NowFunc().Unix()
|
value = stmt.DB.NowFunc().Unix()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -664,7 +664,7 @@ func (field *Field) setupValuerAndSetter() {
|
||||||
if field.AutoCreateTime == UnixNanosecond || field.AutoUpdateTime == UnixNanosecond {
|
if field.AutoCreateTime == UnixNanosecond || field.AutoUpdateTime == UnixNanosecond {
|
||||||
field.ReflectValueOf(ctx, value).SetInt(data.UnixNano())
|
field.ReflectValueOf(ctx, value).SetInt(data.UnixNano())
|
||||||
} else if field.AutoCreateTime == UnixMillisecond || field.AutoUpdateTime == UnixMillisecond {
|
} else if field.AutoCreateTime == UnixMillisecond || field.AutoUpdateTime == UnixMillisecond {
|
||||||
field.ReflectValueOf(ctx, value).SetInt(data.UnixNano() / 1e6)
|
field.ReflectValueOf(ctx, value).SetInt(data.UnixMilli())
|
||||||
} else {
|
} else {
|
||||||
field.ReflectValueOf(ctx, value).SetInt(data.Unix())
|
field.ReflectValueOf(ctx, value).SetInt(data.Unix())
|
||||||
}
|
}
|
||||||
|
@ -673,7 +673,7 @@ func (field *Field) setupValuerAndSetter() {
|
||||||
if field.AutoCreateTime == UnixNanosecond || field.AutoUpdateTime == UnixNanosecond {
|
if field.AutoCreateTime == UnixNanosecond || field.AutoUpdateTime == UnixNanosecond {
|
||||||
field.ReflectValueOf(ctx, value).SetInt(data.UnixNano())
|
field.ReflectValueOf(ctx, value).SetInt(data.UnixNano())
|
||||||
} else if field.AutoCreateTime == UnixMillisecond || field.AutoUpdateTime == UnixMillisecond {
|
} else if field.AutoCreateTime == UnixMillisecond || field.AutoUpdateTime == UnixMillisecond {
|
||||||
field.ReflectValueOf(ctx, value).SetInt(data.UnixNano() / 1e6)
|
field.ReflectValueOf(ctx, value).SetInt(data.UnixMilli())
|
||||||
} else {
|
} else {
|
||||||
field.ReflectValueOf(ctx, value).SetInt(data.Unix())
|
field.ReflectValueOf(ctx, value).SetInt(data.Unix())
|
||||||
}
|
}
|
||||||
|
@ -738,7 +738,7 @@ func (field *Field) setupValuerAndSetter() {
|
||||||
if field.AutoCreateTime == UnixNanosecond || field.AutoUpdateTime == UnixNanosecond {
|
if field.AutoCreateTime == UnixNanosecond || field.AutoUpdateTime == UnixNanosecond {
|
||||||
field.ReflectValueOf(ctx, value).SetUint(uint64(data.UnixNano()))
|
field.ReflectValueOf(ctx, value).SetUint(uint64(data.UnixNano()))
|
||||||
} else if field.AutoCreateTime == UnixMillisecond || field.AutoUpdateTime == UnixMillisecond {
|
} else if field.AutoCreateTime == UnixMillisecond || field.AutoUpdateTime == UnixMillisecond {
|
||||||
field.ReflectValueOf(ctx, value).SetUint(uint64(data.UnixNano() / 1e6))
|
field.ReflectValueOf(ctx, value).SetUint(uint64(data.UnixMilli()))
|
||||||
} else {
|
} else {
|
||||||
field.ReflectValueOf(ctx, value).SetUint(uint64(data.Unix()))
|
field.ReflectValueOf(ctx, value).SetUint(uint64(data.Unix()))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue