mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Changing to client_encoding, adding test for creating a connection
This commit is contained in:
parent
d69070529c
commit
f658b31aed
@ -38,7 +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 = config.encoding || defaults.encoding;
|
||||
this.client_encoding = config.client_encoding || defaults.client_encoding;
|
||||
//a domain socket begins with '/'
|
||||
this.isDomainSocket = (!(this.host||'').indexOf('/'));
|
||||
};
|
||||
@ -63,7 +63,7 @@ ConnectionParameters.prototype.getLibpqConnectionString = function(cb) {
|
||||
return cb(null, params.join(' '));
|
||||
}
|
||||
if(this.client_encoding) {
|
||||
params.push(this.client_encoding);
|
||||
params.push("client_encoding='" + this.client_encoding + "'");
|
||||
}
|
||||
dns.lookup(this.host, function(err, address) {
|
||||
if(err) return cb(err, null);
|
||||
|
||||
@ -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…
x
Reference in New Issue
Block a user