This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always raise 'error' event for non-query errors
For brianc/node-postgres#1503. Not backwards-compatible (semver major).
- Loading branch information
1 parent
25d12eb
commit 8fecf7a
Showing
2 changed files
with
20 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict' | ||
|
||
var Client = require('../') | ||
var assert = require('assert') | ||
|
||
describe('connection errors', function () { | ||
it('raise error events', function (done) { | ||
var client = new Client() | ||
client.connectSync() | ||
client.query('SELECT pg_terminate_backend(pg_backend_pid())', assert.fail) | ||
client.on('error', function (err) { | ||
assert(/^server closed the connection unexpectedly/.test(err.message)) | ||
assert.strictEqual(client.pq.resultErrorFields().sqlState, '57P01') | ||
client.end() | ||
done() | ||
}) | ||
}) | ||
}) |