Open
Show file tree
Hide file tree
Changes from all commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Failed to load files.
Add support for password function to native
  • Loading branch information
mjgp2 committedOct 24, 2022
commit 07ac095ee9dc0f91c70310b052e5e478c03da176
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,9 +125,25 @@ class ConnectionParameters {
}

getLibpqConnectionString(cb) {
var params = []
add(params, this, 'user')
add(params, this, 'password')
if (typeof this.password === 'function') {
const pw = this.password();
if (typeof pw === 'string') {
return this._getLibpqConnectionString(cb, pw)
}
pw.then((pwString) => this._getLibpqConnectionString(cb, pwString)).catch((e) => cb(e))
return
}
this._getLibpqConnectionString(cb);
}

_getLibpqConnectionString(cb, pw) {
var params = [];
add(params, this, 'user');
if (pw != null) {
params.push('password=' + quoteParamValue(pw))
} else {
add(params, this, 'password');
}
add(params, this, 'port')
add(params, this, 'application_name')
add(params, this, 'fallback_application_name')
Expand Down