Skip to content

Commit 8ce808d

Browse files
committed
Merge pull request brianc#281 from adunstan/unix-domain-socket
Fix Unix domain socket setting. closes brianc#277
2 parents 69b4171 + ed015f9 commit 8ce808d

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

lib/connection-parameters.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ConnectionParameters.prototype.getLibpqConnectionString = function(cb) {
5858
params.push("dbname='" + this.database + "'");
5959
}
6060
if(this.isDomainSocket) {
61-
params.push("host=" + this.getDomainSocketName());
61+
params.push("host=" + this.host);
6262
return cb(null, params.join(' '));
6363
}
6464
params.push("options=--client_encoding='utf-8'");
@@ -69,14 +69,4 @@ ConnectionParameters.prototype.getLibpqConnectionString = function(cb) {
6969
});
7070
};
7171

72-
ConnectionParameters.prototype.getDomainSocketName = function() {
73-
var filename = '.s.PGSQL.' + this.port;
74-
75-
//if host is full path to socket fd with port number, just return it
76-
if(this.host.indexOf(filename) > -1) return this.host;
77-
78-
//otherwise, build it from host + standard filename + port
79-
return path.join(this.host, filename);
80-
};
81-
8272
module.exports = ConnectionParameters;

test/unit/connection-parameters/creation-tests.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,6 @@ test('initializing with unix domain socket', function() {
5353
assert.equal(subject.host, '/var/run/');
5454
});
5555

56-
test('builds domain socket', function() {
57-
var subject = new ConnectionParameters({
58-
host: '/var/run/',
59-
port: 1234
60-
});
61-
assert.equal(subject.getDomainSocketName(), '/var/run/.s.PGSQL.1234');
62-
subject.host = '/tmp';
63-
assert.equal(subject.getDomainSocketName(), '/tmp/.s.PGSQL.1234');
64-
assert.equal(subject.getDomainSocketName(), '/tmp/.s.PGSQL.1234');
65-
});
66-
6756
test('libpq connection string building', function() {
6857
var checkForPart = function(array, part) {
6958
assert.ok(array.indexOf(part) > -1, array.join(" ") + " did not contain " + part);
@@ -131,7 +120,7 @@ test('libpq connection string building', function() {
131120
assert.isNull(err);
132121
var parts = constring.split(" ");
133122
checkForPart(parts, "user='brian'");
134-
checkForPart(parts, "host=/tmp/.s.PGSQL.5432");
123+
checkForPart(parts, "host=/tmp/");
135124
}));
136125
});
137126

0 commit comments

Comments
 (0)