Skip to content

Commit d690705

Browse files
committed
Makes encoding an optional parameter
1 parent bbf9459 commit d690705

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/connection-parameters.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var ConnectionParameters = function(config) {
3838
this.password = val('password', config);
3939
this.binary = val('binary', config);
4040
this.ssl = config.ssl || defaults.ssl;
41+
this.client_encoding = config.encoding || defaults.encoding;
4142
//a domain socket begins with '/'
4243
this.isDomainSocket = (!(this.host||'').indexOf('/'));
4344
};
@@ -61,7 +62,9 @@ ConnectionParameters.prototype.getLibpqConnectionString = function(cb) {
6162
params.push("host=" + this.host);
6263
return cb(null, params.join(' '));
6364
}
64-
params.push("client_encoding='utf-8'");
65+
if(this.client_encoding) {
66+
params.push(this.client_encoding);
67+
}
6568
dns.lookup(this.host, function(err, address) {
6669
if(err) return cb(err, null);
6770
params.push("hostaddr=" + address);

lib/defaults.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ module.exports = {
3131
reapIntervalMillis: 1000,
3232

3333
//pool log function / boolean
34-
poolLog: false
34+
poolLog: false,
35+
36+
encoding: ""
3537
};

0 commit comments

Comments
 (0)