Merge pull request #370 from badave/master
Makes client_encoding configurable and optional
This commit is contained in:
commit
d525528f4f
@ -38,6 +38,7 @@ var ConnectionParameters = function(config) {
|
||||
this.password = val('password', config);
|
||||
this.binary = val('binary', config);
|
||||
this.ssl = config.ssl || defaults.ssl;
|
||||
this.client_encoding = val("client_encoding", config);
|
||||
//a domain socket begins with '/'
|
||||
this.isDomainSocket = (!(this.host||'').indexOf('/'));
|
||||
};
|
||||
@ -61,7 +62,9 @@ ConnectionParameters.prototype.getLibpqConnectionString = function(cb) {
|
||||
params.push("host=" + this.host);
|
||||
return cb(null, params.join(' '));
|
||||
}
|
||||
params.push("client_encoding='utf-8'");
|
||||
if(this.client_encoding) {
|
||||
params.push("client_encoding='" + this.client_encoding + "'");
|
||||
}
|
||||
dns.lookup(this.host, function(err, address) {
|
||||
if(err) return cb(err, null);
|
||||
params.push("hostaddr=" + address);
|
||||
|
@ -31,5 +31,7 @@ module.exports = {
|
||||
reapIntervalMillis: 1000,
|
||||
|
||||
//pool log function / boolean
|
||||
poolLog: false
|
||||
poolLog: false,
|
||||
|
||||
client_encoding: ""
|
||||
};
|
||||
|
@ -124,6 +124,18 @@ test('libpq connection string building', function() {
|
||||
}));
|
||||
});
|
||||
|
||||
test("encoding can be specified by config", function() {
|
||||
var config = {
|
||||
client_encoding: "utf-8"
|
||||
}
|
||||
var subject = new ConnectionParameters(config);
|
||||
subject.getLibpqConnectionString(assert.calls(function(err, constring) {
|
||||
assert.isNull(err);
|
||||
var parts = constring.split(" ");
|
||||
checkForPart(parts, "client_encoding='utf-8'");
|
||||
}));
|
||||
})
|
||||
|
||||
test('password contains < and/or > characters', function () {
|
||||
return false;
|
||||
var sourceConfig = {
|
||||
|
Loading…
Reference in New Issue
Block a user