clickhouse-go
clickhouse-go copied to clipboard
Backslash insert issue using named parameters
Observed
When I insert \ string as a named parameter - it fails, as well as \\
Expected behaviour
It has to be inserted like a regular string
Code example
package main
import (
"context"
"fmt"
"github.com/ClickHouse/clickhouse-go/v2"
"github.com/google/uuid"
"log"
)
func main() {
chConn, err := clickhouse.Open(&clickhouse.Options{
Addr: []string{fmt.Sprintf("%s:9000", "localhost")},
Auth: clickhouse.Auth{
Database: "test",
Username: "test",
Password: "test",
},
Compression: &clickhouse.Compression{
Method: clickhouse.CompressionLZ4,
},
})
if err != nil {
log.Fatal(err)
}
// it works
err = chConn.Exec(context.Background(),
`INSERT INTO named_issue (id, email) VALUES ({id:String}, {email:String})`,
clickhouse.Named("id", uuid.New().String()), clickhouse.Named("email", "[email protected]"))
if err != nil {
log.Fatal(err)
}
fmt.Println("Query 1 executed")
// doesn't work
err = chConn.Exec(context.Background(),
`INSERT INTO named_issue (id, email) VALUES ({id:String}, {email:String})`,
clickhouse.Named("id", uuid.New().String()), clickhouse.Named("email", "\\"))
if err != nil {
log.Fatal(err)
}
fmt.Println("Query 2 executed")
}
Error log
code: 26, message: Cannot parse quoted string: expected closing quote
Details
Environment
- [ ]
clickhouse-goversion: v2.30.0 - [ ] Interface: ?
- [ ] Go version: go1.23.0
- [ ] Operating system:
- [ ] ClickHouse version: 24.9.2.42
- [ ] Is it a ClickHouse Cloud? No
- [ ] ClickHouse Server non-default settings, if any:
- [ ]
CREATE TABLEstatements for tables involved:
CREATE TABLE named_issue (
id UUID,
email String
)
ENGINE = MergeTree()
PRIMARY KEY (id);