clickhouse
Advanced tools
Comparing version 2.4.0 to 2.4.1
@@ -16,3 +16,3 @@ /// <reference types="node" /> | ||
export class WriteStream extends Stream.Transform { | ||
writeRow(data: Array<any>): Promise<void>; | ||
writeRow(data: Array<any> | string): Promise<void>; | ||
exec(): Promise<{}>; | ||
@@ -19,0 +19,0 @@ } |
21
index.js
@@ -287,3 +287,5 @@ 'use strict'; | ||
if (Array.isArray(data)) { | ||
if (typeof data === 'string') { | ||
row = data; | ||
} else if (Array.isArray(data)) { | ||
row = ClickHouse.mapRowAsArray(data); | ||
@@ -402,4 +404,6 @@ } else if (isObject(data)) { | ||
if (Array.isArray(data) && Array.isArray(data[0])) { | ||
if(Array.isArray(data) && data.every(d => typeof d === 'string')) { | ||
values = data; | ||
} else if (Array.isArray(data) && Array.isArray(data[0])) { | ||
values = data; | ||
} else if (Array.isArray(data) && isObject(data[0])) { | ||
@@ -425,2 +429,5 @@ values = data; | ||
return values.map(row => { | ||
if (typeof row === 'string') { | ||
return row; | ||
} | ||
if (isFirstElObject) { | ||
@@ -520,6 +527,8 @@ return ClickHouse.mapRowAsObject(fieldList, row); | ||
if (query.match(/values/i)) { | ||
// | ||
if (data && data.every(d => typeof d === 'string')) { | ||
params['body'] = me._getBodyForInsert(); | ||
} | ||
} else { | ||
query += ' FORMAT TabSeparated'; | ||
if (data) { | ||
@@ -814,3 +823,3 @@ params['body'] = me._getBodyForInsert(); | ||
if (u.protocol === 'https:' && port === 443) { | ||
if (u.protocol === 'https:' && (port === 443 || !opts.port)) { | ||
u.port = ''; | ||
@@ -823,3 +832,2 @@ } else if (! u.port && port) { | ||
if (this.opts.user || this.opts.username) { | ||
@@ -829,2 +837,3 @@ this.opts.username = this.opts.user || this.opts.username; | ||
if (this.opts.config) { | ||
@@ -831,0 +840,0 @@ const { database } = this.opts.config; |
@@ -54,3 +54,3 @@ { | ||
"JSONStream": "1.3.4", | ||
"lodash": "4.17.19", | ||
"lodash": "4.17.21", | ||
"querystring": "0.2.0", | ||
@@ -95,3 +95,3 @@ "request": "2.88.0", | ||
"types": "index.d.ts", | ||
"version": "2.4.0" | ||
"version": "2.4.1" | ||
} |
@@ -201,6 +201,19 @@ # clickhouse | ||
**Run Tests**: | ||
``` | ||
npm install | ||
npm run test | ||
# or | ||
# node_modules/.bin/mocha --timeout 60000 --slow 5000 -f "SPECIFIC TEST NAME" | ||
``` | ||
*** | ||
**Changelogs**: | ||
* 2021-04-20 (v2.4.0) Remove usage default username by default | ||
* 2020-11-02 (v2.4.1) | ||
- Merge list of PR | ||
- fix test with Base Auth check | ||
* 2020-11-02 (v2.2.0) ___Backward Incompatible Change___ | ||
- port from url more important then port from config | ||
- port from url more important than port from config | ||
* 2020-04-17 (v2.1.0) | ||
@@ -207,0 +220,0 @@ - Fix query with totals. For json formats work perfect, but for another - doesn't |
@@ -428,2 +428,9 @@ 'use strict'; | ||
}); | ||
it('default HTTPS port is 433', async () => { | ||
const clickhouse = new ClickHouse({ | ||
...config, | ||
url : 'https://localhost' | ||
}); | ||
expect(clickhouse.opts.url).to.match(/localhost\//); | ||
}); | ||
}); | ||
@@ -470,3 +477,59 @@ | ||
}); | ||
it('insert field as raw string', async () => { | ||
clickhouse.sessionId = Date.now(); | ||
const r = await clickhouse.query(` | ||
CREATE TABLE IF NOT EXISTS test_raw_string ( | ||
date Date, | ||
str String, | ||
arr Array(String), | ||
arr2 Array(Date), | ||
arr3 Array(UInt8), | ||
fixedStr String | ||
) ENGINE=MergeTree(date, date, 8192) | ||
`).toPromise(); | ||
expect(r).to.be.ok(); | ||
const rows = [ | ||
'(\'2018-01-01 10:00:00\',\'Вам, проживающим за оргией оргию,\',[],[\'1915-01-02 10:00:00\',\'1915-01-03 10:00:00\'],[1,2,3,4,5],unhex(\'60ed56e75bb93bd353267faa\'))', | ||
'(\'2018-02-01 10:00:00\',\'имеющим ванную и теплый клозет!\',[\'5670000000\',\'asdas dasf\'],[\'1915-02-02 10:00:00\'],[],unhex(\'60ed56f4a88cd5dcb249d959\'))' | ||
]; | ||
const r2 = await clickhouse.insert( | ||
'INSERT INTO test_raw_string (date, str, arr, arr2, arr3, fixedStr) VALUES', | ||
rows | ||
).toPromise(); | ||
expect(r2).to.be.ok(); | ||
}); | ||
it('insert stream accept raw string', async () => { | ||
clickhouse.sessionId = Date.now(); | ||
const r = await clickhouse.query(` | ||
CREATE TABLE IF NOT EXISTS test_insert_stream_raw_string ( | ||
date Date, | ||
str String, | ||
arr Array(String), | ||
arr2 Array(Date), | ||
arr3 Array(UInt8), | ||
fixedStr FixedString(12) | ||
) ENGINE=MergeTree(date, date, 8192) | ||
`).toPromise(); | ||
expect(r).to.be.ok(); | ||
const rows = [ | ||
'(\'2018-01-01 10:00:00\',\'Вам, проживающим за оргией оргию,\',[],[\'1915-01-02 10:00:00\',\'1915-01-03 10:00:00\'],[1,2,3,4,5],unhex(\'60ed56e75bb93bd353267faa\'))', | ||
'(\'2018-02-01 10:00:00\',\'имеющим ванную и теплый клозет!\',[\'5670000000\',\'asdas dasf\'],[\'1915-02-02 10:00:00\'],[],unhex(\'60ed56f4a88cd5dcb249d959\'))' | ||
]; | ||
const stream = await clickhouse.insert( | ||
'INSERT INTO test_insert_stream_raw_string (date, str, arr, arr2, arr3, fixedStr) VALUES', | ||
).stream(); | ||
stream.writeRow(rows[0]); | ||
stream.writeRow(rows[1]); | ||
const r2 = await stream.exec(); | ||
expect(r2).to.be.ok(); | ||
}); | ||
it('select, insert and two pipes', async () => { | ||
@@ -473,0 +536,0 @@ const result = await clickhouse.query('DROP TABLE IF EXISTS session_temp').toPromise(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57667
1636
230
+ Addedlodash@4.17.21(transitive)
- Removedlodash@4.17.19(transitive)
Updatedlodash@4.17.21