forked from mirror/gorm
[mssql] Fix save time struct's timezone
This commit is contained in:
parent
6f64b8610d
commit
969ab67636
|
@ -79,11 +79,11 @@ func TestCreateWithExistingTimestamp(t *testing.T) {
|
||||||
var newUser User
|
var newUser User
|
||||||
DB.First(&newUser, user.Id)
|
DB.First(&newUser, user.Id)
|
||||||
|
|
||||||
if newUser.CreatedAt.Format(time.RFC3339) != timeA.Format(time.RFC3339) {
|
if newUser.CreatedAt.UTC().Format(time.RFC3339) != timeA.UTC().Format(time.RFC3339) {
|
||||||
t.Errorf("CreatedAt should not be changed")
|
t.Errorf("CreatedAt should not be changed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if newUser.UpdatedAt.Format(time.RFC3339) != timeA.Format(time.RFC3339) {
|
if newUser.UpdatedAt.UTC().Format(time.RFC3339) != timeA.UTC().Format(time.RFC3339) {
|
||||||
t.Errorf("UpdatedAt should not be changed")
|
t.Errorf("UpdatedAt should not be changed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ func (s *mssql) DataTypeOf(field *gorm.StructField) string {
|
||||||
}
|
}
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
if _, ok := dataValue.Interface().(time.Time); ok {
|
if _, ok := dataValue.Interface().(time.Time); ok {
|
||||||
sqlType = "datetime2"
|
sqlType = "datetimeoffset"
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if gorm.IsByteArrayOrSlice(dataValue) {
|
if gorm.IsByteArrayOrSlice(dataValue) {
|
||||||
|
|
Loading…
Reference in New Issue