Migrate from gorp to sqlx in store/sqlstore/job_store.go (#18518)

Этот коммит содержится в:
Shobhit Gupta
2021-10-19 06:59:24 -07:00
коммит произвёл GitHub
родитель 93f956e478
Коммит e12e0df447
3 изменённых файлов: 69 добавлений и 34 удалений

Просмотреть файл

@@ -58,15 +58,15 @@ var AllJobTypes = [...]string{
}
type Job struct {
Id string `json:"id"`
Type string `json:"type"`
Priority int64 `json:"priority"`
CreateAt int64 `json:"create_at"`
StartAt int64 `json:"start_at"`
LastActivityAt int64 `json:"last_activity_at"`
Status string `json:"status"`
Progress int64 `json:"progress"`
Data map[string]string `json:"data"`
Id string `json:"id"`
Type string `json:"type"`
Priority int64 `json:"priority"`
CreateAt int64 `json:"create_at"`
StartAt int64 `json:"start_at"`
LastActivityAt int64 `json:"last_activity_at"`
Status string `json:"status"`
Progress int64 `json:"progress"`
Data StringMap `json:"data"`
}
func (j *Job) IsValid() *AppError {

Просмотреть файл

@@ -98,6 +98,25 @@ func (sa *StringArray) Scan(value interface{}) error {
return errors.New("received value is neither a byte slice nor string")
}
// Scan converts database column value to StringMap
func (m *StringMap) Scan(value interface{}) error {
if value == nil {
return nil
}
buf, ok := value.([]byte)
if ok {
return json.Unmarshal(buf, m)
}
str, ok := value.(string)
if ok {
return json.Unmarshal([]byte(str), m)
}
return errors.New("received value is neither a byte slice nor string")
}
var translateFunc i18n.TranslateFunc
var translateFuncOnce sync.Once