upstep bun to v1.0.14 (#291)

This commit is contained in:
tobi 2021-10-24 13:14:37 +02:00 committed by GitHub
commit 8b7c3507fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
100 changed files with 5071 additions and 3836 deletions

View file

@ -4,11 +4,9 @@ import (
"encoding/hex"
"math"
"strconv"
"time"
"unicode/utf8"
"github.com/uptrace/bun/internal"
"github.com/uptrace/bun/internal/parser"
)
func AppendError(b []byte, err error) []byte {
@ -78,55 +76,16 @@ func AppendString(b []byte, s string) []byte {
return b
}
func AppendBytes(b []byte, bytes []byte) []byte {
if bytes == nil {
func AppendBytes(b, bs []byte) []byte {
if bs == nil {
return AppendNull(b)
}
b = append(b, `'\x`...)
s := len(b)
b = append(b, make([]byte, hex.EncodedLen(len(bytes)))...)
hex.Encode(b[s:], bytes)
b = append(b, '\'')
return b
}
func AppendTime(b []byte, tm time.Time) []byte {
b = append(b, '\'')
b = tm.UTC().AppendFormat(b, "2006-01-02 15:04:05.999999-07:00")
b = append(b, '\'')
return b
}
func AppendJSON(b, jsonb []byte) []byte {
b = append(b, '\'')
p := parser.New(jsonb)
for p.Valid() {
c := p.Read()
switch c {
case '"':
b = append(b, '"')
case '\'':
b = append(b, "''"...)
case '\000':
continue
case '\\':
if p.SkipBytes([]byte("u0000")) {
b = append(b, `\\u0000`...)
} else {
b = append(b, '\\')
if p.Valid() {
b = append(b, p.Read())
}
}
default:
b = append(b, c)
}
}
b = append(b, make([]byte, hex.EncodedLen(len(bs)))...)
hex.Encode(b[s:], bs)
b = append(b, '\'')