summaryrefslogtreecommitdiffstats
path: root/store/sql_store.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2015-11-06 09:05:32 -0500
committerJoram Wilander <jwawilander@gmail.com>2015-11-06 09:05:32 -0500
commit1ecad4301e6e511a426da5884a54111c5bb7a4fd (patch)
tree114dea884f0a08729f5b6b5f9e45d2e470bedc71 /store/sql_store.go
parent6417d4728dc9351d5bf3180e458be8ce6e1e642f (diff)
parent195728b949a4f3aee75e01f4b0e4a0b2f67850da (diff)
downloadchat-1ecad4301e6e511a426da5884a54111c5bb7a4fd.tar.gz
chat-1ecad4301e6e511a426da5884a54111c5bb7a4fd.tar.bz2
chat-1ecad4301e6e511a426da5884a54111c5bb7a4fd.zip
Merge pull request #1327 from florianorben/PLT-857-2
PLT-857: Support `attachments` for Incoming Webhooks
Diffstat (limited to 'store/sql_store.go')
-rw-r--r--store/sql_store.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/store/sql_store.go b/store/sql_store.go
index e5c540e06..f348db10b 100644
--- a/store/sql_store.go
+++ b/store/sql_store.go
@@ -455,6 +455,20 @@ func IsUniqueConstraintError(err string, mysql string, postgres string) bool {
return unique && field
}
+func (ss SqlStore) GetColumnDataType(tableName, columnName string) string {
+ dataType, err := ss.GetMaster().SelectStr("SELECT data_type FROM INFORMATION_SCHEMA.COLUMNS where table_name = :Tablename AND column_name = :Columnname", map[string]interface{}{
+ "Tablename": tableName,
+ "Columnname": columnName,
+ })
+ if err != nil {
+ l4g.Critical("Failed to get data type for column %s from table %s: %v", columnName, tableName, err.Error())
+ time.Sleep(time.Second)
+ panic("Failed to get get data type for column " + columnName + " from table " + tableName + ": " + err.Error())
+ }
+
+ return dataType
+}
+
func (ss SqlStore) GetMaster() *gorp.DbMap {
return ss.master
}
@@ -529,6 +543,8 @@ func (me mattermConverter) ToDb(val interface{}) (interface{}, error) {
return model.ArrayToJson(t), nil
case model.EncryptStringMap:
return encrypt([]byte(utils.Cfg.SqlSettings.AtRestEncryptKey), model.MapToJson(t))
+ case model.StringInterface:
+ return model.StringInterfaceToJson(t), nil
}
return val, nil
@@ -572,6 +588,16 @@ func (me mattermConverter) FromDb(target interface{}) (gorp.CustomScanner, bool)
return json.Unmarshal(b, target)
}
return gorp.CustomScanner{new(string), target, binder}, true
+ case *model.StringInterface:
+ binder := func(holder, target interface{}) error {
+ s, ok := holder.(*string)
+ if !ok {
+ return errors.New("FromDb: Unable to convert StringInterface to *string")
+ }
+ b := []byte(*s)
+ return json.Unmarshal(b, target)
+ }
+ return gorp.CustomScanner{new(string), target, binder}, true
}
return gorp.CustomScanner{}, false