Extract binary_parameters handle logic into public methods for external use (#20043)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2576556c8b
Коммит
6608f3a9ca
@@ -5,6 +5,7 @@ package sqlstore
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
@@ -156,3 +157,16 @@ func (l *morphWriter) Write(in []byte) (int, error) {
|
||||
mlog.Debug(string(in))
|
||||
return len(in), nil
|
||||
}
|
||||
|
||||
func DSNHasBinaryParam(dsn string) (bool, error) {
|
||||
url, err := url.Parse(dsn)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return url.Query().Get("binary_parameters") == "yes", nil
|
||||
}
|
||||
|
||||
// AppendBinaryFlag updates the byte slice to work using binary_parameters=yes.
|
||||
func AppendBinaryFlag(buf []byte) []byte {
|
||||
return append([]byte{0x01}, buf...)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user