drop supports also on cluster

This commit is contained in:
Francesco Rivola
2021-12-09 15:35:06 +01:00
parent caf1343c20
commit 5facaf909a
2 changed files with 10 additions and 5 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|create)/i)) {
if (query.match(/^(select|show|exists|create|drop)/i)) {
if ( ! R_FORMAT_PARSER.test(query)) {
query += ` FORMAT ${ClickHouse.getFullFormatName(me.format)}`;
}

View File

@@ -36,14 +36,19 @@ before(async () => {
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 = `
it('should be able to create and drop a table', async () => {
const createTableQuery = `
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();
const createTableQueryResult = await clickhouse.query(createTableQuery).toPromise();
expect(createTableQueryResult).to.be.ok();
const dropTableQuery = `
DROP TABLE ${database}.test_on_cluster ON CLUSTER test_cluster;`;
const dropTableQueryResult = await clickhouse.query(dropTableQuery).toPromise();
expect(dropTableQueryResult).to.be.ok();
});
});