Skip to content

Cannot insert data into the table with ' ' (space) in one of its column name. #30

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

Closed
pakapor opened this issue Feb 27, 2020 · 0 comments

Comments

@pakapor
Copy link
Contributor

pakapor commented Feb 27, 2020

From one of the example cases, if I put the column name test id and run the insert function, the program throws the exception.

Example Code:

#include <clickhouse/client.h>
using namespace clickhouse;

/// Initialize client connection.
Client client(ClientOptions().SetHost("localhost"));

/// Create a table.
client.Execute("CREATE TABLE IF NOT EXISTS test.numbers (\`test id\` UInt64, name String) ENGINE = Memory");

/// Insert some values.
try {
	Block block;

	auto id = std::make_shared<ColumnUInt64>();
	id->Append(1);
	id->Append(7);

	auto name = std::make_shared<ColumnString>();
	name->Append("one");
	name->Append("seven");

	block.AppendColumn("test id"  , id);
	block.AppendColumn("name", name);

	client.Insert("test.numbers", block);
} catch (std::exception &e) {
	printf("Error: %s\n", e.what());
}

Error: DB::Exception: Syntax error: failed at position 33: id,name ) VALUES. Expected one of: token, ClosingRoundBracket, Comma, Dot

I then tried putting ' " and ` around the column name for the data block, it throws on another line instead.

block.AppendColumn("`test id`" , id);

Error: DB::Exception: Not found column test id in block. There are only columns: test id, name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant