mirror of
https://github.com/lingble/clickhouse.git
synced 2025-11-20 21:05:05 +00:00
provide support for on cluster create table queries
This commit is contained in:
2
index.js
2
index.js
@@ -492,7 +492,7 @@ class QueryCursor {
|
|||||||
// Hack for Sequelize ORM
|
// Hack for Sequelize ORM
|
||||||
query = query.trim().trimEnd().replace(/;$/gm, "");
|
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)) {
|
if ( ! R_FORMAT_PARSER.test(query)) {
|
||||||
query += ` FORMAT ${ClickHouse.getFullFormatName(me.format)}`;
|
query += ` FORMAT ${ClickHouse.getFullFormatName(me.format)}`;
|
||||||
}
|
}
|
||||||
|
|||||||
13
test/test.js
13
test/test.js
@@ -34,6 +34,19 @@ before(async () => {
|
|||||||
await temp.query(`CREATE DATABASE ${database}`).toPromise();
|
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', () => {
|
describe('Exec', () => {
|
||||||
it('should return not null object', async () => {
|
it('should return not null object', async () => {
|
||||||
const sqlList = [
|
const sqlList = [
|
||||||
|
|||||||
Reference in New Issue
Block a user