Comparing version 0.14.1 to 0.15.0
@@ -174,2 +174,11 @@ var crypto = require('crypto'); | ||
con.once('end', function() { | ||
if(self.activeQuery) { | ||
self.activeQuery.handleError(new Error('Stream unexpectedly ended during query execution')); | ||
self.activeQuery = null; | ||
} | ||
self.emit('end'); | ||
}); | ||
con.on('notice', function(msg) { | ||
@@ -176,0 +185,0 @@ self.emit('notice', msg); |
@@ -43,2 +43,6 @@ var net = require('net'); | ||
this.stream.on('end', function() { | ||
self.emit('end'); | ||
}); | ||
if(this.ssl) { | ||
@@ -45,0 +49,0 @@ this.stream.once('data', function(buffer) { |
@@ -201,2 +201,11 @@ //require the c++ bindings & export to javascript | ||
connection.on('_end', function() { | ||
process.nextTick(function() { | ||
if(connection._activeQuery) { | ||
connection._activeQuery.handleError(new Error("Connection was ended during query")); | ||
} | ||
connection.emit('end'); | ||
}); | ||
}); | ||
connection.on('_readyForQuery', function() { | ||
@@ -203,0 +212,0 @@ var q = this._activeQuery; |
@@ -8,3 +8,7 @@ ### v1.0 - not released yet | ||
### v0.15.0 | ||
- client now emits `end` when disconnected from back-end server | ||
- if client is disconnected in the middle of a query, query receives an error | ||
### v0.14.0 | ||
@@ -11,0 +15,0 @@ |
{ | ||
"name": "pg", | ||
"version": "0.14.1", | ||
"version": "0.15.0", | ||
"description": "PostgreSQL client - pure javascript & libpq with the same API", | ||
@@ -25,3 +25,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"jshint": "git://github.com/jshint/jshint.git" | ||
"jshint": "1.1.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "scripts": { |
@@ -161,4 +161,14 @@ var helper = require(__dirname + '/test-helper'); | ||
}); | ||
}); | ||
test('query receives error on client shutdown', function() { | ||
var client = new Client(helper.config); | ||
client.connect(assert.calls(function() { | ||
client.query('SELECT pg_sleep(5)', assert.calls(function(err, res) { | ||
assert(err); | ||
})); | ||
client.end(); | ||
assert.emits(client, 'end'); | ||
})); | ||
}); | ||
@@ -8,8 +8,10 @@ var helper = require(__dirname + "/../test-helper"); | ||
assert.emits(client, 'connect', function() { | ||
assert.throws(function() { | ||
client.query({text:{fail: true}}); | ||
}) | ||
client.end(); | ||
}) | ||
}) | ||
assert.emits(client, 'end', function() { | ||
assert.throws(function() { | ||
client.query({text:{fail: true}}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -20,11 +22,13 @@ test('parameterized query with non-text as first parameter throws error', function() { | ||
assert.emits(client, 'connect', function() { | ||
assert.throws(function() { | ||
client.query({ | ||
text: {fail: true}, | ||
values: [1, 2] | ||
}) | ||
}) | ||
client.end(); | ||
}) | ||
}) | ||
assert.emits(client, 'end', function() { | ||
assert.throws(function() { | ||
client.query({ | ||
text: {fail: true}, | ||
values: [1, 2] | ||
}) | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -42,22 +46,26 @@ var connect = function(callback) { | ||
connect(function(client) { | ||
assert.throws(function() { | ||
client.query("SELECT *", "LKSDJF") | ||
}) | ||
client.end(); | ||
}) | ||
}) | ||
assert.emits(client, 'end', function() { | ||
assert.throws(function() { | ||
client.query("SELECT *", "LKSDJF") | ||
}); | ||
}); | ||
}); | ||
}); | ||
test('config', function() { | ||
connect(function(client) { | ||
assert.throws(function() { | ||
client.query({ | ||
text: "SELECT *", | ||
values: "ALSDKFJ" | ||
}) | ||
}) | ||
client.end(); | ||
}) | ||
}) | ||
}) | ||
assert.emits(client, 'end', function() { | ||
assert.throws(function() { | ||
client.query({ | ||
text: "SELECT *", | ||
values: "ALSDKFJ" | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
274445
107
7273
205