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.go27
1 files changed, 26 insertions, 1 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 e9170588..c88d9100 100644
--- a/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go
+++ b/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go
@@ -76,7 +76,12 @@ func (sa StringArray) Equals(input StringArray) bool {
// Value converts StringArray to database value
func (sa StringArray) Value() (driver.Value, error) {
- return json.Marshal(sa)
+ j, err := json.Marshal(sa)
+ if err != nil {
+ return nil, err
+ }
+ // non utf8 characters are not supported https://mattermost.atlassian.net/browse/MM-41066
+ return string(j), err
}
// Scan converts database column value to StringArray
@@ -117,6 +122,16 @@ func (m *StringMap) Scan(value interface{}) error {
return errors.New("received value is neither a byte slice nor string")
}
+// Value converts StringMap to database value
+func (m StringMap) Value() (driver.Value, error) {
+ j, err := json.Marshal(m)
+ if err != nil {
+ return nil, err
+ }
+ // non utf8 characters are not supported https://mattermost.atlassian.net/browse/MM-41066
+ return string(j), err
+}
+
func (si *StringInterface) Scan(value interface{}) error {
if value == nil {
return nil
@@ -135,6 +150,16 @@ func (si *StringInterface) Scan(value interface{}) error {
return errors.New("received value is neither a byte slice nor string")
}
+// Value converts StringInterface to database value
+func (si StringInterface) Value() (driver.Value, error) {
+ j, err := json.Marshal(si)
+ if err != nil {
+ return nil, err
+ }
+ // non utf8 characters are not supported https://mattermost.atlassian.net/browse/MM-41066
+ return string(j), err
+}
+
var translateFunc i18n.TranslateFunc
var translateFuncOnce sync.Once