-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c85dd9
commit 0ac8d94
Showing
2 changed files
with
25 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ describe('ClickhouseSchema Tests', () => { | |
email: { type: ClickhouseTypes.CHString }, | ||
age: { type: ClickhouseTypes.CHUInt8 } | ||
} | ||
const options: ChSchemaOptions = { | ||
const options: ChSchemaOptions<typeof schemaDefinition> = { | ||
primary_key: 'id', | ||
table_name: 'users_table' | ||
} | ||
|
@@ -26,7 +26,7 @@ describe('ClickhouseSchema Tests', () => { | |
email: { type: ClickhouseTypes.CHString }, | ||
age: { type: ClickhouseTypes.CHUInt8 } | ||
} | ||
const options: ChSchemaOptions = { | ||
const options: ChSchemaOptions<typeof schemaDefinition> = { | ||
table_name: 'users_table' | ||
} | ||
|
||
|
@@ -42,7 +42,7 @@ describe('ClickhouseSchema Tests', () => { | |
email: { type: ClickhouseTypes.CHString }, | ||
age: { type: ClickhouseTypes.CHUInt8 } | ||
} | ||
const options: ChSchemaOptions = { | ||
const options: ChSchemaOptions<typeof schemaDefinition> = { | ||
primary_key: 'id', | ||
table_name: 'users_table' | ||
} | ||
|
@@ -60,7 +60,7 @@ describe('ClickhouseSchema Tests', () => { | |
email: { type: ClickhouseTypes.CHString, default: '[email protected]' }, | ||
age: { type: ClickhouseTypes.CHUInt8 } | ||
} | ||
const options: ChSchemaOptions = { | ||
const options: ChSchemaOptions<typeof schemaDefinition> = { | ||
primary_key: 'id', | ||
table_name: 'users_table' | ||
} | ||
|
@@ -78,7 +78,7 @@ describe('ClickhouseSchema Tests', () => { | |
email: { type: ClickhouseTypes.CHString, default: '[email protected]' }, | ||
age: { type: ClickhouseTypes.CHUInt8, default: 18 } | ||
} | ||
const options: ChSchemaOptions = { | ||
const options: ChSchemaOptions<typeof schemaDefinition> = { | ||
primary_key: 'id', | ||
table_name: 'users_table', | ||
additional_options: ['COMMENT \'This table provides user details\''] | ||
|
@@ -95,7 +95,7 @@ describe('ClickhouseSchema Tests', () => { | |
name: { type: ClickhouseTypes.CHString, default: 'John Doe' }, | ||
email: { type: ClickhouseTypes.CHString } | ||
} | ||
const options: ChSchemaOptions = { | ||
const options: ChSchemaOptions<typeof schemaDefinition> = { | ||
table_name: 'users_table', | ||
order_by: 'id' | ||
} | ||
|
@@ -111,7 +111,7 @@ describe('ClickhouseSchema Tests', () => { | |
name: { type: ClickhouseTypes.CHString, default: 'John Doe' }, | ||
email: { type: ClickhouseTypes.CHString } | ||
} | ||
const options: ChSchemaOptions = { | ||
const options: ChSchemaOptions<typeof schemaDefinition> = { | ||
table_name: 'users_table', | ||
primary_key: 'id', | ||
on_cluster: 'users_cluster' | ||
|
@@ -123,19 +123,18 @@ describe('ClickhouseSchema Tests', () => { | |
}) | ||
|
||
it('should correctly generate a create table query with a specified engine', () => { | ||
const schemaDefinition = { | ||
const schema = new ClickhouseSchema({ | ||
id: { type: ClickhouseTypes.CHUUID }, | ||
name: { type: ClickhouseTypes.CHString, default: 'John Doe' }, | ||
email: { type: ClickhouseTypes.CHString } | ||
} | ||
const options: ChSchemaOptions = { | ||
}, { | ||
table_name: 'users_table', | ||
primary_key: 'id', | ||
engine: 'ReplicatedMergeTree()' | ||
} | ||
const schema = new ClickhouseSchema(schemaDefinition, options) | ||
}) | ||
const expectedQuery = 'CREATE TABLE IF NOT EXISTS users_table\n(\nid UUID,\nname String DEFAULT \'John Doe\',\nemail String\n)\nENGINE = ReplicatedMergeTree()\nPRIMARY KEY id' | ||
const query = schema.GetCreateTableQuery() | ||
console.log(query) | ||
expect(query).toEqual(expectedQuery) | ||
}) | ||
|
||
|
@@ -145,7 +144,7 @@ describe('ClickhouseSchema Tests', () => { | |
name: { type: ClickhouseTypes.CHString, default: 'John Doe' }, | ||
email: { type: ClickhouseTypes.CHString } | ||
} | ||
const options: ChSchemaOptions = { | ||
const options: ChSchemaOptions<typeof schemaDefinition> = { | ||
database: 'users_db', | ||
table_name: 'users_table', | ||
primary_key: 'id' | ||
|
@@ -162,7 +161,7 @@ describe('ClickhouseSchema Tests', () => { | |
name: { type: ClickhouseTypes.CHString, default: 'John Doe' }, | ||
email: { type: ClickhouseTypes.CHString } | ||
} | ||
const options: ChSchemaOptions = { | ||
const options: ChSchemaOptions<typeof schemaDefinition> = { | ||
table_name: 'users_table', | ||
primary_key: 'id', | ||
on_cluster: 'users_cluster', | ||
|
@@ -192,7 +191,7 @@ describe('ClickhouseSchema Tests', () => { | |
name: { type: ClickhouseTypes.CHString, default: 'John Doe' }, | ||
email: { type: ClickhouseTypes.CHString } | ||
} | ||
const options: ChSchemaOptions = { | ||
const options: ChSchemaOptions<typeof schemaDefinition> = { | ||
table_name: 'users_table', | ||
primary_key: 'id', | ||
on_cluster: 'users_cluster', | ||
|