summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/dialect/append.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-10-24 13:14:37 +0200
committerLibravatar GitHub <noreply@github.com>2021-10-24 13:14:37 +0200
commit8b7c3507fe0c8f6e921ee2de2c170ef93eeb7275 (patch)
treee79e3f5a59fb8942de79955bd26bf665be0acce8 /vendor/github.com/uptrace/bun/dialect/append.go
parentdocs typo fix (#290) (diff)
downloadgotosocial-8b7c3507fe0c8f6e921ee2de2c170ef93eeb7275.tar.xz
upstep bun to v1.0.14 (#291)
Diffstat (limited to 'vendor/github.com/uptrace/bun/dialect/append.go')
-rw-r--r--vendor/github.com/uptrace/bun/dialect/append.go49
1 files changed, 4 insertions, 45 deletions
diff --git a/vendor/github.com/uptrace/bun/dialect/append.go b/vendor/github.com/uptrace/bun/dialect/append.go
index 01e80745a..c9d137946 100644
--- a/vendor/github.com/uptrace/bun/dialect/append.go
+++ b/vendor/github.com/uptrace/bun/dialect/append.go
@@ -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, '\'')