2
0

Merge pull request #547 from kingluo/patch-1

cast bytea to make []byte suitable for both string and binary string
This commit is contained in:
Jack Christensen
2019-06-29 12:02:57 -04:00
committed by GitHub
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ func QuoteString(str string) string {
} }
func QuoteBytes(buf []byte) string { func QuoteBytes(buf []byte) string {
return `'\x` + hex.EncodeToString(buf) + "'" return `'\x` + hex.EncodeToString(buf) + "'::bytea"
} }
type sqlLexer struct { type sqlLexer struct {
+1 -1
View File
@@ -108,7 +108,7 @@ func TestQuerySanitize(t *testing.T) {
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}}, query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}},
args: []interface{}{[]byte{0, 1, 2, 3, 255}}, args: []interface{}{[]byte{0, 1, 2, 3, 255}},
expected: `select '\x00010203ff'`, expected: `select '\x00010203ff'::bytea`,
}, },
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}}, query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}},