summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/dialect/pgdialect/array_parser.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/pgdialect/array_parser.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/pgdialect/array_parser.go')
-rw-r--r--vendor/github.com/uptrace/bun/dialect/pgdialect/array_parser.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/vendor/github.com/uptrace/bun/dialect/pgdialect/array_parser.go b/vendor/github.com/uptrace/bun/dialect/pgdialect/array_parser.go
index 1c927fca0..0dff754f8 100644
--- a/vendor/github.com/uptrace/bun/dialect/pgdialect/array_parser.go
+++ b/vendor/github.com/uptrace/bun/dialect/pgdialect/array_parser.go
@@ -2,6 +2,7 @@ package pgdialect
import (
"bytes"
+ "encoding/hex"
"fmt"
"io"
)
@@ -109,11 +110,29 @@ func (p *arrayParser) readSubstring() ([]byte, error) {
}
continue
}
+ if c == '\'' && next == '\'' {
+ p.buf = append(p.buf, next)
+ c, err = p.readByte()
+ if err != nil {
+ return nil, err
+ }
+ continue
+ }
p.buf = append(p.buf, c)
c = next
}
+ if bytes.HasPrefix(p.buf, []byte("\\x")) && len(p.buf)%2 == 0 {
+ data := p.buf[2:]
+ buf := make([]byte, hex.DecodedLen(len(data)))
+ n, err := hex.Decode(buf, data)
+ if err != nil {
+ return nil, err
+ }
+ return buf[:n], nil
+ }
+
return p.buf, nil
}