Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert statement not support column name identifier with double quotes #1049

Closed
senekis opened this issue Jul 31, 2023 · 0 comments · Fixed by #1083
Closed

Insert statement not support column name identifier with double quotes #1049

senekis opened this issue Jul 31, 2023 · 0 comments · Fixed by #1083
Labels

Comments

@senekis
Copy link

senekis commented Jul 31, 2023

Describe the bug

Having the following insert statement: INSERT INTO "foo"."bar" ("id") VALUES (?), returns the following error block cannot be sorted - missing columns in requested order: [id], this error was introduced in the PR #790 to enforce sort order of columns.

Accordingly with the documentation https://clickhouse.com/docs/en/sql-reference/syntax#identifiers

If you want to use identifiers the same as keywords or you want to use other symbols in identifiers, quote it using double quotes or backticks, for example, "id", id.

Expected behaviour

Should accept column name identifiers with double quotes besides the backticks

Code example

package main

import (
	"context"
	"log"

	"github.com/ClickHouse/clickhouse-go/v2"
)

func main() {
	conn, err := clickhouse.Open(&clickhouse.Options{
		Addr: []string{"127.0.0.1:9000"},
	})
	if err != nil {
		log.Fatal(err)
	}

	ctx := context.Background()
	err = conn.Exec(ctx, `
		CREATE TABLE IF NOT EXISTS example (
			  id String
		) Engine = Memory
	`)
	if err != nil {
		log.Fatal(err)
	}

	_, err = conn.PrepareBatch(ctx, "INSERT INTO example (`id`)")
	if err != nil {
		log.Fatal(err)
	}
}

Error log

block cannot be sorted - missing columns in requested order: [id]

Configuration

Environment

  • Client version: 23.5.1.672 (official build).
  • Language version: clickhouse-go v2.12.0
  • OS: Darwin arm64
  • Interface: ClickHouse API / database/sql compatible driver

ClickHouse server

  • ClickHouse Server version: 23.5.1 revision 54462.
  • ClickHouse Server non-default settings, if any:
  • CREATE TABLE statements for tables involved:
  • Sample data for all these tables, use clickhouse-obfuscator if necessary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant