Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: brianc/node-postgres
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.0.5
Choose a base ref
...
head repository: brianc/node-postgres
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.1.0
Choose a head ref
  • 3 commits
  • 6 files changed
  • 1 contributor

Commits on Aug 11, 2016

  1. Add callback to client#end (#1106)

    A long standing bug was the pure JS client didn't accept or call a callback on `client.end`.  This is inconsistent with both the documentation & general node patterns.
    
    This fixes the issue & adds a test.  The issue did not exist in the native version of the client.
    brianc authored Aug 11, 2016
    Copy the full SHA
    a536afb View commit details
  2. Update changelog

    brianc committed Aug 11, 2016
    Copy the full SHA
    4251a09 View commit details
  3. Bump version

    brianc committed Aug 11, 2016
    Copy the full SHA
    42689da View commit details
Showing with 20 additions and 4 deletions.
  1. +4 −0 CHANGELOG.md
  2. +4 −1 lib/client.js
  3. +3 −0 lib/connection.js
  4. +1 −1 package.json
  5. +6 −0 test/integration/client/end-callback-tests.js
  6. +2 −2 test/integration/test-helper.js
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@ For richer information consult the commit log on github with referenced pull req

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

### v6.1.0

- Add optional callback parameter to the pure JavaScript `client.end` method. The native client already supported this.

### v6.0.0

#### Breaking Changes
5 changes: 4 additions & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
@@ -336,8 +336,11 @@ Client.prototype.query = function(config, values, callback) {
return query;
};

Client.prototype.end = function() {
Client.prototype.end = function(cb) {
this.connection.end();
if (cb) {
this.connection.once('end', cb);
}
};

Client.md5 = function(string) {
3 changes: 3 additions & 0 deletions lib/connection.js
Original file line number Diff line number Diff line change
@@ -122,6 +122,9 @@ Connection.prototype.attachListeners = function(stream) {
packet = self._reader.read();
}
});
stream.on('end', function() {
self.emit('end');
});
};

Connection.prototype.requestSsl = function() {
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg",
"version": "6.0.4",
"version": "6.1.0",
"description": "PostgreSQL client - pure javascript & libpq with the same API",
"keywords": [
"postgres",
6 changes: 6 additions & 0 deletions test/integration/client/end-callback-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var helper = require('./test-helper')

var client = helper.client(assert.success(function() {
client.end(assert.success(function() {
}))
}))
4 changes: 2 additions & 2 deletions test/integration/test-helper.js
Original file line number Diff line number Diff line change
@@ -7,9 +7,9 @@ if(helper.args.native) {
}

//creates a client from cli parameters
helper.client = function() {
helper.client = function(cb) {
var client = new Client(helper.config);
client.connect();
client.connect(cb);
return client;
};