ClickHouse / ClickHouse/clickhouse-go

How to bind string without quotes

Open
#1,635 9 comments 0 reactions 0 assignees View on GitHub
bug investigate query-params
Dominant language
Go
Stars
3.3k
Forks
684
Avg merge
2d 3h
Merged PRs (30d)
14

Description

## Observed

Hi! Is it possible to bind string without quotes? For example to create database. For now ClickHouse throws an exception: `code: 62, message: Syntax error: failed at position 31 (''test_db''): 'test_db' ENGINE = 'Atomic'. Expected identifier`. Can't find anything similar in [format](https://github.com/ClickHouse/clickhouse-go/blob/7bbaf83f60c4d90f8a23115b37954af9d18313fb/bind.go#L280) func.

## Code example

```go
conn.Exec(ctx, "CREATE DATABASE ? ENGINE = ?", name, engineFull)
```

## Error log

```log
code: 62, message: Syntax error: failed at position 31 (''test_db''): 'test_db' ENGINE = 'Atomic'. Expected identifier
```

## Details

### Environment
* [x] `clickhouse-go` version: 2.33.1
* [x] Interface: ClickHouse API / `database/sql` compatible driver
* [x] Go version: 1.23.0
* [x] Operating system: linux/macos
* [x] ClickHouse version: 24.8
* [ ] Is it a ClickHouse Cloud?
* [ ] ClickHouse Server non-default settings, if any:
* [ ] `CREATE TABLE` statements for tables involved:
* [ ] Sample data for all these tables, use [clickhouse-obfuscator](https://github.com/ClickHouse/ClickHouse/blob/master/programs/obfuscator/Obfuscator.cpp#L42-L80) if necessary

Contributor guide

Open the contributing guide

Research direction

Start by reading the binding logic in bind.go around the referenced format function, then reproduce the CREATE DATABASE example with the database/sql-compatible interface. Determine how identifier arguments are handled versus string values, and use the existing binding tests or add focused coverage so the requested identifier syntax and current value quoting are both verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.