Migrating bot store to use sqlx (#18300)
https://community-daily.mattermost.com/boards/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4?c=5da060fd-8fbc-449d-8219-c73a9dd0bd7c ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
22b33c625b
Коммит
21a53320d3
@@ -78,6 +78,21 @@ func (w *sqlxDBWrapper) NamedExec(query string, arg interface{}) (sql.Result, er
|
||||
return w.DB.NamedExecContext(ctx, query, arg)
|
||||
}
|
||||
|
||||
func (w *sqlxDBWrapper) Exec(query string, args ...interface{}) (sql.Result, error) {
|
||||
query = w.DB.Rebind(query)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), w.queryTimeout)
|
||||
defer cancel()
|
||||
|
||||
if w.trace {
|
||||
defer func(then time.Time) {
|
||||
printArgs(query, time.Since(then), args)
|
||||
}(time.Now())
|
||||
}
|
||||
|
||||
return w.DB.ExecContext(ctx, query, args...)
|
||||
}
|
||||
|
||||
func (w *sqlxDBWrapper) NamedQuery(query string, arg interface{}) (*sqlx.Rows, error) {
|
||||
if w.DB.DriverName() == model.DatabaseDriverPostgres {
|
||||
query = namedParamRegex.ReplaceAllStringFunc(query, strings.ToLower)
|
||||
@@ -164,6 +179,21 @@ func (w *sqlxTxWrapper) Get(dest interface{}, query string, args ...interface{})
|
||||
return w.Tx.GetContext(ctx, dest, query, args...)
|
||||
}
|
||||
|
||||
func (w *sqlxTxWrapper) Exec(query string, args ...interface{}) (sql.Result, error) {
|
||||
query = w.Tx.Rebind(query)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), w.queryTimeout)
|
||||
defer cancel()
|
||||
|
||||
if w.trace {
|
||||
defer func(then time.Time) {
|
||||
printArgs(query, time.Since(then), args)
|
||||
}(time.Now())
|
||||
}
|
||||
|
||||
return w.Tx.ExecContext(ctx, query, args...)
|
||||
}
|
||||
|
||||
func (w *sqlxTxWrapper) NamedExec(query string, arg interface{}) (sql.Result, error) {
|
||||
if w.Tx.DriverName() == model.DatabaseDriverPostgres {
|
||||
query = namedParamRegex.ReplaceAllStringFunc(query, strings.ToLower)
|
||||
|
||||
Ссылка в новой задаче
Block a user