mirror of
https://github.com/lingble/clickhouse.git
synced 2025-11-07 14:38:07 +00:00
Fix username & password use
This commit is contained in:
@@ -84,6 +84,7 @@ Exec by callback way:
|
|||||||
clickhouse.query(query).exec(function (err, rows) {
|
clickhouse.query(query).exec(function (err, rows) {
|
||||||
...
|
...
|
||||||
});
|
});
|
||||||
|
````
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
|
|||||||
16
index.js
16
index.js
@@ -599,11 +599,27 @@ class ClickHouse {
|
|||||||
} else if (query.match(/^insert/i)) {
|
} else if (query.match(/^insert/i)) {
|
||||||
reqParams['url'] = me.url + '?query=' + encodeURIComponent(query + ' FORMAT TabSeparated') + '&' + querystring.stringify(configQS);
|
reqParams['url'] = me.url + '?query=' + encodeURIComponent(query + ' FORMAT TabSeparated') + '&' + querystring.stringify(configQS);
|
||||||
|
|
||||||
|
if (me.opts.username) {
|
||||||
|
reqParams['url'] = reqParams['url'] + '&user=' + me.opts.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.opts.password) {
|
||||||
|
reqParams['url'] = reqParams['url'] + '&password=' + me.opts.password;
|
||||||
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
reqParams['body'] = me._getBodyForInsert(query, data);
|
reqParams['body'] = me._getBodyForInsert(query, data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reqParams['url'] = me.url + '?query=' + encodeURIComponent(query) + '&' + querystring.stringify(configQS);
|
reqParams['url'] = me.url + '?query=' + encodeURIComponent(query) + '&' + querystring.stringify(configQS);
|
||||||
|
|
||||||
|
if (me.opts.username) {
|
||||||
|
reqParams['url'] = reqParams['url'] + '&user=' + me.opts.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.opts.password) {
|
||||||
|
reqParams['url'] = reqParams['url'] + '&password=' + me.opts.password;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reqParams['headers'] = {
|
reqParams['headers'] = {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "clickhouse",
|
"name": "clickhouse",
|
||||||
"version": "1.2.14",
|
"version": "1.2.15",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/TimonKK/clickhouse.git"
|
"url": "https://github.com/TimonKK/clickhouse.git"
|
||||||
|
|||||||
Reference in New Issue
Block a user