Fix actionlog's meta type enc/dec
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
package actionlog
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -227,3 +231,22 @@ func NewSeverity(s string) Severity {
|
||||
|
||||
return Debug
|
||||
}
|
||||
|
||||
func (m *Meta) Scan(value interface{}) error {
|
||||
//lint:ignore S1034 This typecast is intentional, we need to get []byte out of a []uint8
|
||||
switch value.(type) {
|
||||
case nil:
|
||||
*m = Meta{}
|
||||
case []uint8:
|
||||
aux := value.([]byte)
|
||||
if err := json.Unmarshal(aux, m); err != nil {
|
||||
return errors.Wrapf(err, "cannot scan '%v' into Meta", string(aux))
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m Meta) Value() (driver.Value, error) {
|
||||
return json.Marshal(m)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user