1
1
mirror of https://github.com/go-gitea/gitea synced 2025-09-28 03:28:13 +00:00

upgrade xorm to v1.0.6 (#14246)

This commit is contained in:
Lunny Xiao
2021-01-05 14:28:51 +08:00
committed by GitHub
parent 8db0372a45
commit 126c9331d6
19 changed files with 91 additions and 24 deletions

View File

@@ -168,7 +168,29 @@ func (session *Session) bytes2Value(col *schemas.Column, fieldValue *reflect.Val
} else if strings.EqualFold(sdata, "false") {
x = 0
} else {
x, err = strconv.ParseInt(sdata, 10, 64)
if col.SQLType.Name == schemas.DateTime {
if len(sdata) == 20 {
t, err := time.Parse("2006-01-02T15:04:05Z", sdata)
if err != nil {
return fmt.Errorf("arg %v as int: %s", key, err.Error())
}
x = t.Unix()
} else if len(sdata) == 19 {
var parseFormat = "2006-01-02 15:04:05"
if sdata[10] == 'T' {
parseFormat = "2006-01-02T15:04:05"
}
t, err := time.Parse(parseFormat, sdata)
if err != nil {
return fmt.Errorf("arg %v as int: %s", key, err.Error())
}
x = t.Unix()
} else {
x, err = strconv.ParseInt(sdata, 10, 64)
}
} else {
x, err = strconv.ParseInt(sdata, 10, 64)
}
}
if err != nil {
return fmt.Errorf("arg %v as int: %s", key, err.Error())