summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server/v6/model/utils.go')
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v6/model/utils.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go b/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go
index c57716f7..e9170588 100644
--- a/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go
+++ b/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go
@@ -98,6 +98,43 @@ 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")
+}
+
+func (si *StringInterface) Scan(value interface{}) error {
+ if value == nil {
+ return nil
+ }
+
+ buf, ok := value.([]byte)
+ if ok {
+ return json.Unmarshal(buf, si)
+ }
+
+ str, ok := value.(string)
+ if ok {
+ return json.Unmarshal([]byte(str), si)
+ }
+
+ return errors.New("received value is neither a byte slice nor string")
+}
+
var translateFunc i18n.TranslateFunc
var translateFuncOnce sync.Once