provide support for on cluster create table queries

This commit is contained in:
Francesco Rivola
2021-12-09 15:04:10 +01:00
parent a84d890a1d
commit caf1343c20
2 changed files with 14 additions and 1 deletions

View File

@@ -492,7 +492,7 @@ class QueryCursor {
// Hack for Sequelize ORM
query = query.trim().trimEnd().replace(/;$/gm, "");
if (query.match(/^(select|show|exists)/i)) {
if (query.match(/^(select|show|exists|create)/i)) {
if ( ! R_FORMAT_PARSER.test(query)) {
query += ` FORMAT ${ClickHouse.getFullFormatName(me.format)}`;
}

View File

@@ -34,6 +34,19 @@ before(async () => {
await temp.query(`CREATE DATABASE ${database}`).toPromise();
});
describe('On cluster', () => {
// Note: this test only works with ClickHouse setup as Cluster named test_cluster
it('should be able to create table', async () => {
const query = `
CREATE TABLE ${database}.test_on_cluster ON CLUSTER test_cluster (
test String
)
ENGINE=MergeTree ORDER BY test;`;
const r = await clickhouse.query(query).toPromise();
expect(r).to.be.ok();
});
});
describe('Exec', () => {
it('should return not null object', async () => {
const sqlList = [