Skip to content

Commit a78786f

Browse files
author
Andrew Derbitov
committedFeb 14, 2019
Fix username & password use
1 parent 9bccb1d commit a78786f

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed
 

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Exec by callback way:
8484
clickhouse.query(query).exec(function (err, rows) {
8585
...
8686
});
87+
````
8788
8889
***
8990

‎index.js

+16
Original file line numberDiff line numberDiff line change
@@ -599,11 +599,27 @@ class ClickHouse {
599599
} else if (query.match(/^insert/i)) {
600600
reqParams['url'] = me.url + '?query=' + encodeURIComponent(query + ' FORMAT TabSeparated') + '&' + querystring.stringify(configQS);
601601

602+
if (me.opts.username) {
603+
reqParams['url'] = reqParams['url'] + '&user=' + me.opts.username;
604+
}
605+
606+
if (this.opts.password) {
607+
reqParams['url'] = reqParams['url'] + '&password=' + me.opts.password;
608+
}
609+
602610
if (data) {
603611
reqParams['body'] = me._getBodyForInsert(query, data);
604612
}
605613
} else {
606614
reqParams['url'] = me.url + '?query=' + encodeURIComponent(query) + '&' + querystring.stringify(configQS);
615+
616+
if (me.opts.username) {
617+
reqParams['url'] = reqParams['url'] + '&user=' + me.opts.username;
618+
}
619+
620+
if (this.opts.password) {
621+
reqParams['url'] = reqParams['url'] + '&password=' + me.opts.password;
622+
}
607623
}
608624

609625
reqParams['headers'] = {

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
}
3232
],
3333
"name": "clickhouse",
34-
"version": "1.2.14",
34+
"version": "1.2.15",
3535
"repository": {
3636
"type": "git",
3737
"url": "https://github.com/TimonKK/clickhouse.git"

0 commit comments

Comments
 (0)
Please sign in to comment.