diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-06-28 10:34:00 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-06-28 07:34:00 -0700 |
commit | 005dd0754ba6dec00d8e4a84a297d0f35fbefb2b (patch) | |
tree | 9a21ff859d987cb067371939f37e385d97f92e03 /vendor/github.com/mattermost/gorp/gorp.go | |
parent | 2dea567dcfcdfcd016c0da55a120c6e854760fb0 (diff) | |
download | chat-005dd0754ba6dec00d8e4a84a297d0f35fbefb2b.tar.gz chat-005dd0754ba6dec00d8e4a84a297d0f35fbefb2b.tar.bz2 chat-005dd0754ba6dec00d8e4a84a297d0f35fbefb2b.zip |
Update gorp to support query timeouts on postgres (#6730)
* Update gorp to support query timeouts on postgres
* Update help text to remove postgres exception
* Fix glide.lock
Diffstat (limited to 'vendor/github.com/mattermost/gorp/gorp.go')
-rw-r--r-- | vendor/github.com/mattermost/gorp/gorp.go | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/vendor/github.com/mattermost/gorp/gorp.go b/vendor/github.com/mattermost/gorp/gorp.go index 728971e48..784712fd9 100644 --- a/vendor/github.com/mattermost/gorp/gorp.go +++ b/vendor/github.com/mattermost/gorp/gorp.go @@ -173,13 +173,9 @@ func exec(e SqlExecutor, query string, doTimeout bool, args ...interface{}) (sql query, args = maybeExpandNamedQuery(dbMap, query, args) } - if doTimeout && dbMap.Dialect.Name() != "PostgresDialect" { - ctx, cancel := context.WithTimeout(context.Background(), dbMap.QueryTimeout) - defer cancel() - return executor.ExecContext(ctx, query, args...) - } else { - return executor.Exec(query, args...) - } + ctx, cancel := context.WithTimeout(context.Background(), dbMap.QueryTimeout) + defer cancel() + return executor.ExecContext(ctx, query, args...) } // maybeExpandNamedQuery checks the given arg to see if it's eligible to be used @@ -410,14 +406,9 @@ func get(m *DbMap, exec SqlExecutor, i interface{}, dest[x] = target } - var row *sql.Row - if m.Dialect.Name() != "PostgresDialect" { - ctx, cancel := context.WithTimeout(context.Background(), m.QueryTimeout) - defer cancel() - row = exec.QueryRowContext(ctx, plan.query, keys...) - } else { - row = exec.QueryRow(plan.query, keys...) - } + ctx, cancel := context.WithTimeout(context.Background(), m.QueryTimeout) + defer cancel() + row := exec.QueryRowContext(ctx, plan.query, keys...) err = row.Scan(dest...) if err != nil { |