Skip to content

Commit 9ad0159

Browse files
committed
merge with upstream
2 parents 2d1024c + 30fc4c2 commit 9ad0159

File tree

9 files changed

+155
-151
lines changed

9 files changed

+155
-151
lines changed

NEWS.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ For richer information consult the commit log on github with referenced pull req
44

55
We do not include break-fix version release in this file.
66

7+
### v2.9.0
8+
- Add better support for [unix domain socket](https://github.com/brianc/node-postgres/pull/487) connections
9+
710
### v2.8.0
811
- Add support for parsing JSON[] and UUID[] result types
912

binding.gyp

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
'targets': [
33
{
44
'target_name': 'binding',
5+
'sources': ['src/binding.cc'],
6+
'include_dirs': [
7+
'<!@(pg_config --includedir)',
8+
'<!(node -e "require(\'nan\')")'
9+
],
510
'conditions' : [
611
['OS=="win"', {
712
'conditions' : [
813
['"<!@(cmd /C where /Q pg_config || echo n)"!="n"',
914
{
10-
'sources': ['src/binding.cc'],
11-
'include_dirs': ['<!@(pg_config --includedir)'],
1215
'libraries' : ['libpq.lib'],
1316
'msvs_settings': {
1417
'VCLinkerTool' : {
@@ -24,8 +27,6 @@
2427
'conditions' : [
2528
['"y"!="n"', # ToDo: add pg_config existance condition that works on linux
2629
{
27-
'sources': ['src/binding.cc'],
28-
'include_dirs': ['<!@(pg_config --includedir)'],
2930
'libraries' : ['-lpq -L<!@(pg_config --libdir)']
3031
}
3132
]

lib/connection-parameters.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@ var val = function(key, config) {
1212
var url = require('url');
1313
//parses a connection string
1414
var parse = function(str) {
15+
var config;
1516
//unix socket
1617
if(str.charAt(0) === '/') {
17-
return { host: str };
18+
config = str.split(' ');
19+
return { host: config[0], database: config[1] };
1820
}
1921
// url parse expects spaces encoded as %20
20-
str = encodeURI(str);
22+
if(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(str)) str = encodeURI(str);
2123
var result = url.parse(str, true);
22-
var config = {};
24+
config = {};
25+
if(result.protocol == 'socket:') {
26+
config.host = decodeURI(result.pathname);
27+
config.database = result.query.db;
28+
config.client_encoding = result.query.encoding;
29+
return config;
30+
}
2331
config.host = result.hostname;
24-
config.database = result.pathname ? result.pathname.slice(1) : null;
32+
config.database = result.pathname ? decodeURI(result.pathname.slice(1)) : null;
2533
var auth = (result.auth || ':').split(':');
2634
config.user = auth[0];
2735
config.password = auth[1];

lib/types/textParsers.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ var arrayParser = require(__dirname + "/arrayParser.js");
33
//parses PostgreSQL server formatted date strings into javascript date objects
44
var parseDate = function(isoDate) {
55
//TODO this could do w/ a refactor
6-
var dateMatcher = /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?/;
6+
var dateMatcher = /(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?/;
77

88
var match = dateMatcher.exec(isoDate);
99
//could not parse date
1010
if(!match) {
11-
dateMatcher = /^(\d{4})-(\d{2})-(\d{2})$/;
11+
dateMatcher = /^(\d{1,})-(\d{2})-(\d{2})$/;
1212
match = dateMatcher.test(isoDate);
1313
if(!match) {
1414
return null;

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pg",
3-
"version": "2.8.3",
3+
"version": "2.9.0",
44
"description": "PostgreSQL client - pure javascript & libpq with the same API",
55
"keywords": [
66
"postgres",
@@ -20,7 +20,8 @@
2020
"dependencies": {
2121
"generic-pool": "2.0.3",
2222
"buffer-writer": "1.0.0",
23-
"pgpass": "0.0.1"
23+
"pgpass": "0.0.1",
24+
"nan": "~0.6.0"
2425
},
2526
"devDependencies": {
2627
"jshint": "1.1.0",

0 commit comments

Comments
 (0)