pg 6.0.2 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ For richer information consult the commit log on github with referenced pull req
4
4
 
5
5
  We do not include break-fix version release in this file.
6
6
 
7
+ ### v6.1.0
8
+
9
+ - Add optional callback parameter to the pure JavaScript `client.end` method. The native client already supported this.
10
+
7
11
  ### v6.0.0
8
12
 
9
13
  #### Breaking Changes
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/brianc/node-postgres.svg?branch=master)](http://travis-ci.org/brianc/node-postgres)
4
4
  [![Dependency Status](https://david-dm.org/brianc/node-postgres.svg)](https://david-dm.org/brianc/node-postgres)
5
+ <span class="badge-npmversion"><a href="https://npmjs.org/package/pg" title="View this project on NPM"><img src="https://img.shields.io/npm/v/pg.svg" alt="NPM version" /></a></span>
6
+ <span class="badge-npmdownloads"><a href="https://npmjs.org/package/pg" title="View this project on NPM"><img src="https://img.shields.io/npm/dm/pg.svg" alt="NPM downloads" /></a></span>
5
7
 
6
8
  Non-blocking PostgreSQL client for node.js. Pure JavaScript and optional native libpq bindings.
7
9
 
@@ -20,7 +22,7 @@ var pg = require('pg');
20
22
 
21
23
  // instantiate a new client
22
24
  // the client will read connection information from
23
- // the same environment varaibles used by postgres cli tools
25
+ // the same environment variables used by postgres cli tools
24
26
  var client = new pg.Client();
25
27
 
26
28
  // connect to our database
@@ -109,26 +111,6 @@ It's __highly recommended__ you read the documentation for [pg-pool](https://git
109
111
 
110
112
  [Here is an up & running quickly example](https://github.com/brianc/node-postgres/wiki/Example)
111
113
 
112
- ### connect to self signed Postgresql server
113
-
114
- Use following config to connect a Postgresql Server self signed:
115
-
116
- ```
117
- var config = {
118
- database : 'database-name', //env var: PGDATABASE
119
- host : "host-or-ip", //env var: PGPORT
120
- port : 5432, //env var: PGPORT
121
- max : 100, // max number of clients in the pool
122
- idleTimeoutMillis: 30000,
123
- ssl : {
124
- rejectUnauthorized : false,
125
- ca : fs.readFileSync("/path/to/server-certificates/maybe/root.crt").toString(),
126
- key : fs.readFileSync("/path/to/client-key/maybe/postgresql.key").toString(),
127
- cert : fs.readFileSync("/path/to/client-certificates/maybe/postgresql.crt").toString(),
128
- }
129
- };
130
-
131
- ```
132
114
 
133
115
  For more information about `config.ssl` check [TLS (SSL) of nodejs](https://nodejs.org/dist/latest-v4.x/docs/api/tls.html)
134
116
 
@@ -157,7 +139,17 @@ var Pool = pg.Pool // good! a pool bound to the native client
157
139
  var Client = pg.Client // good! this client uses libpq bindings
158
140
  ```
159
141
 
160
- node-postgres abstracts over the pg-native module to provide exactly the same interface as the pure JavaScript version. Care has been taken to keep the number of api differences between the two modules to a minimum; however, it is recommended you use either the pure JavaScript or native bindings in both development and production and don't mix & match them in the same process - it can get confusing!
142
+ #### API differences
143
+
144
+ node-postgres abstracts over the pg-native module to provide the same interface as the pure JavaScript version. Care has been taken to keep the number of api differences between the two modules to a minimum.
145
+ However, currently some differences remain, especially :
146
+ * the error object in pg-native is different : notably, the information about the postgres error code is not present in field `code` but in the field `sqlState` , and the name of a few other fields is different (see https://github.com/brianc/node-postgres/issues/938, https://github.com/brianc/node-postgres/issues/972).
147
+ So for example, if you rely on error.code in your application, your will have to adapt your code to work with native bindings.
148
+ * the notification object has a few less properties (see https://github.com/brianc/node-postgres/issues/1045)
149
+ * column objects have less properties (see https://github.com/brianc/node-postgres/issues/988)
150
+ * the modules https://github.com/brianc/node-pg-copy-streams and https://github.com/brianc/node-pg-query-stream do not work with native bindings (you will have to require 'pg' to use them).
151
+
152
+ Thus, it is recommended you use either the pure JavaScript or native bindings in both development and production and don't mix & match them in the same process - it can get confusing!
161
153
 
162
154
  ## Features
163
155
 
package/lib/client.js CHANGED
@@ -336,8 +336,11 @@ Client.prototype.query = function(config, values, callback) {
336
336
  return query;
337
337
  };
338
338
 
339
- Client.prototype.end = function() {
339
+ Client.prototype.end = function(cb) {
340
340
  this.connection.end();
341
+ if (cb) {
342
+ this.connection.once('end', cb);
343
+ }
341
344
  };
342
345
 
343
346
  Client.md5 = function(string) {
package/lib/connection.js CHANGED
@@ -122,6 +122,9 @@ Connection.prototype.attachListeners = function(stream) {
122
122
  packet = self._reader.read();
123
123
  }
124
124
  });
125
+ stream.on('end', function() {
126
+ self.emit('end');
127
+ });
125
128
  };
126
129
 
127
130
  Connection.prototype.requestSsl = function() {
package/lib/index.js CHANGED
@@ -68,13 +68,13 @@ PG.prototype.connect = function(config, callback) {
68
68
 
69
69
  this._pools[poolName] = this._pools[poolName] || new this.Pool(config);
70
70
  var pool = this._pools[poolName];
71
- pool.connect(callback);
72
71
  if(!pool.listeners('error').length) {
73
72
  //propagate errors up to pg object
74
73
  pool.on('error', function(e) {
75
74
  this.emit('error', e, e.client);
76
75
  }.bind(this));
77
76
  }
77
+ return pool.connect(callback);
78
78
  };
79
79
 
80
80
  // cancel the query running on the given client
@@ -34,8 +34,8 @@ var NativeQuery = module.exports = function(native) {
34
34
 
35
35
  util.inherits(NativeQuery, EventEmitter);
36
36
 
37
- NativeQuery.prototype.then = function(callback) {
38
- return this.promise().then(callback);
37
+ NativeQuery.prototype.then = function(onSuccess, onFailure) {
38
+ return this.promise().then(onSuccess, onFailure);
39
39
  };
40
40
 
41
41
  NativeQuery.prototype.catch = function(callback) {
package/lib/query.js CHANGED
@@ -40,8 +40,8 @@ var Query = function(config, values, callback) {
40
40
 
41
41
  util.inherits(Query, EventEmitter);
42
42
 
43
- Query.prototype.then = function(callback) {
44
- return this.promise().then(callback);
43
+ Query.prototype.then = function(onSuccess, onFailure) {
44
+ return this.promise().then(onSuccess, onFailure);
45
45
  };
46
46
 
47
47
  Query.prototype.catch = function(callback) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg",
3
- "version": "6.0.2",
3
+ "version": "6.1.0",
4
4
  "description": "PostgreSQL client - pure javascript & libpq with the same API",
5
5
  "keywords": [
6
6
  "postgres",
@@ -23,11 +23,12 @@
23
23
  "pg-connection-string": "0.1.3",
24
24
  "pg-pool": "1.*",
25
25
  "pg-types": "1.*",
26
- "pgpass": "0.0.6",
26
+ "pgpass": "1.x",
27
27
  "semver": "4.3.2"
28
28
  },
29
29
  "devDependencies": {
30
30
  "async": "0.9.0",
31
+ "co": "4.6.0",
31
32
  "jshint": "2.5.2",
32
33
  "lodash": "4.13.1",
33
34
  "pg-copy-streams": "0.3.0",