1
0
mirror of https://github.com/uptrace/go-clickhouse.git synced 2025-06-29 00:21:46 +02:00

chore: append bytes like a string. Fixes #43

This commit is contained in:
Vladimir Mihailenco
2022-09-01 10:38:41 +03:00
parent 227c8b52c1
commit 428a11c901

View File

@ -2,11 +2,12 @@ package chschema
import ( import (
"database/sql/driver" "database/sql/driver"
"encoding/hex"
"fmt" "fmt"
"math" "math"
"strconv" "strconv"
"time" "time"
"github.com/uptrace/go-clickhouse/ch/internal"
) )
func Append(fmter Formatter, b []byte, v any) []byte { func Append(fmter Formatter, b []byte, v any) []byte {
@ -116,16 +117,5 @@ func AppendBytes(b []byte, bytes []byte) []byte {
if bytes == nil { if bytes == nil {
return AppendNull(b) return AppendNull(b)
} }
return AppendString(b, internal.String(bytes))
b = append(b, '\'')
tmp := make([]byte, hex.EncodedLen(len(bytes)))
hex.Encode(tmp, bytes)
b = append(b, "\\x"...)
b = append(b, tmp...)
b = append(b, '\'')
return b
} }