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) {
...
});
````
***

View File

@@ -599,11 +599,27 @@ class ClickHouse {
} else if (query.match(/^insert/i)) {
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) {
reqParams['body'] = me._getBodyForInsert(query, data);
}
} else {
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'] = {

View File

@@ -31,7 +31,7 @@
}
],
"name": "clickhouse",
"version": "1.2.14",
"version": "1.2.15",
"repository": {
"type": "git",
"url": "https://github.com/TimonKK/clickhouse.git"