Fix username & password use

This commit is contained in:
Andrew Derbitov
2019-02-14 13:33:31 +03:00
parent 9bccb1d8de
commit a78786fcbb
3 changed files with 18 additions and 1 deletions

View File

@@ -84,6 +84,7 @@ Exec by callback way:
clickhouse.query(query).exec(function (err, rows) { clickhouse.query(query).exec(function (err, rows) {
... ...
}); });
````
*** ***

View File

@@ -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'] = {

View File

@@ -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"