summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2017-07-13 15:12:28 -0400
committerJoramWilander <jwawilander@gmail.com>2017-07-13 15:12:28 -0400
commitb645bd3211c41db43dcf9360aedb1630be451741 (patch)
tree334f1749f1f0311963d3e12c131db788a6b807ee /store
parent26370f6eabe17744f8d23b5f815632cf7493387b (diff)
downloadchat-b645bd3211c41db43dcf9360aedb1630be451741.tar.gz
chat-b645bd3211c41db43dcf9360aedb1630be451741.tar.bz2
chat-b645bd3211c41db43dcf9360aedb1630be451741.zip
Postgres fix
Diffstat (limited to 'store')
-rw-r--r--store/sql_oauth_store.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/store/sql_oauth_store.go b/store/sql_oauth_store.go
index 8e23a8cb2..2e6fe2655 100644
--- a/store/sql_oauth_store.go
+++ b/store/sql_oauth_store.go
@@ -9,6 +9,7 @@ import (
"github.com/mattermost/gorp"
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
)
type SqlOAuthStore struct {
@@ -527,7 +528,14 @@ func (as SqlOAuthStore) deleteApp(transaction *gorp.Transaction, clientId string
func (as SqlOAuthStore) deleteOAuthAppSessions(transaction *gorp.Transaction, clientId string) StoreResult {
result := StoreResult{}
- if _, err := transaction.Exec("DELETE s.* FROM Sessions s INNER JOIN OAuthAccessData o ON o.Token = s.Token WHERE o.ClientId = :Id", map[string]interface{}{"Id": clientId}); err != nil {
+ query := ""
+ if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
+ query = "DELETE FROM Sessions s USING OAuthAccessData o WHERE o.Token = s.Token AND o.ClientId = :Id"
+ } else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
+ query = "DELETE s.* FROM Sessions s INNER JOIN OAuthAccessData o ON o.Token = s.Token WHERE o.ClientId = :Id"
+ }
+
+ if _, err := transaction.Exec(query, map[string]interface{}{"Id": clientId}); err != nil {
result.Err = model.NewLocAppError("SqlOAuthStore.DeleteApp", "store.sql_oauth.delete_app.app_error", nil, "id="+clientId+", err="+err.Error())
return result
}