summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/dialect/append.go
diff options
context:
space:
mode:
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, '\'')