force utf-8 encoding on connect

This commit is contained in:
Arkady Emelyanov 2013-01-26 16:36:09 +04:00 committed by bmc
parent 2e66497511
commit 4c254e8edf
3 changed files with 5 additions and 0 deletions

View File

@ -61,6 +61,7 @@ ConnectionParameters.prototype.getLibpqConnectionString = function(cb) {
params.push("host=" + this.getDomainSocketName()); params.push("host=" + this.getDomainSocketName());
return cb(null, params.join(' ')); return cb(null, params.join(' '));
} }
params.push("options=--client_encoding='utf-8'");
dns.lookup(this.host, function(err, address) { dns.lookup(this.host, function(err, address) {
if(err) return cb(err, null); if(err) return cb(err, null);
params.push("hostaddr=" + address); params.push("hostaddr=" + address);

View File

@ -116,6 +116,8 @@ p.startup = function(config) {
.addCString(config.user) .addCString(config.user)
.addCString('database') .addCString('database')
.addCString(config.database) .addCString(config.database)
.addCString('options')
.addCString("--client_encoding='utf-8'")
.addCString('').flush(); .addCString('').flush();
//this message is sent without a code //this message is sent without a code

View File

@ -23,6 +23,8 @@ test("sends startup message", function() {
.addCString('brian') .addCString('brian')
.addCString('database') .addCString('database')
.addCString('bang') .addCString('bang')
.addCString('options')
.addCString("--client_encoding='utf-8'")
.addCString('').join(true)) .addCString('').join(true))
}); });