Skip to content

Commit 60fd0c4

Browse files
committed
fix unhex and test in local clickhouse
1 parent 2aefd5c commit 60fd0c4

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

interpolate.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,9 @@ func encodeValue(buf []byte, arg interface{}, flavor Flavor) ([]byte, error) {
530530
buf = appendHex(buf, data)
531531

532532
case ClickHouse:
533-
buf = append(buf, "unhex"...)
534-
buf = quoteStringValue(buf, *(*string)(unsafe.Pointer(&data)), flavor)
533+
buf = append(buf, "unhex('"...)
534+
buf = appendHex(buf, data)
535+
buf = append(buf, "')"...)
535536
}
536537

537538
default:

interpolate_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func TestFlavorInterpolate(t *testing.T) {
177177
{
178178
ClickHouse,
179179
"SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?", []interface{}{true, false, float32(1.234567), 9.87654321, []byte(nil), []byte("I'm bytes"), dt, time.Time{}, nil},
180-
"SELECT TRUE, FALSE, 1.234567, 9.87654321, NULL, _binary'I\\'m bytes', '2019-04-24 12:23:34.123457', '0000-00-00', NULL", nil,
180+
"SELECT TRUE, FALSE, 1.234567, 9.87654321, NULL, unhex('49276D206279746573'), '2019-04-24 12:23:34.123457', '0000-00-00', NULL", nil,
181181
},
182182
{
183183
ClickHouse,
@@ -187,7 +187,7 @@ func TestFlavorInterpolate(t *testing.T) {
187187
{
188188
ClickHouse,
189189
"SELECT ?", []interface{}{byteArr},
190-
"SELECT _binary'foo'", nil,
190+
"SELECT unhex('666F6F')", nil,
191191
},
192192
{
193193
ClickHouse,

0 commit comments

Comments
 (0)