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:
@@ -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 {
|
||||||
|
|||||||
@@ -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}},
|
||||||
|
|||||||
Reference in New Issue
Block a user