summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/dialect/pgdialect/array_parser.go
diff options
context:
space:
mode:
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
}