Skip to content

Backslash insert issue using named parameters #1576

Open
@andreyrusanov

Description

@andreyrusanov

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-go version: 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 TABLE statements for tables involved:
CREATE TABLE named_issue (
    id UUID,
    email String
)
ENGINE = MergeTree()
PRIMARY KEY (id);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions