Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(pg-types): update pg-types to 4.0.2 #3372

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/pg-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"homepage": "https://github.com/brianc/node-postgres/tree/master/packages/pg-native",
"dependencies": {
"libpq": "1.8.13",
"pg-types": "^2.1.0"
"pg-types": "^4.0.2"
},
"devDependencies": {
"async": "^0.9.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/pg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"pg-connection-string": "^2.7.0",
"pg-pool": "^3.7.0",
"pg-protocol": "^1.7.0",
"pg-types": "^2.1.0",
"pg-types": "^4.0.2",
"pgpass": "1.x"
},
"devDependencies": {
Expand Down
64 changes: 10 additions & 54 deletions packages/pg/test/unit/client/throw-in-type-parser-tests.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,21 @@
'use strict'
var helper = require('./test-helper')
var Query = require('../../../lib/query')
var types = require('pg-types')
const assert = require('assert')

const suite = new helper.Suite()

var typeParserError = new Error('TEST: Throw in type parsers')
var typeParserError = new TypeError('oid must be an integer: special oid that will throw')

types.setTypeParser('special oid that will throw', function () {
throw typeParserError
})

const emitFakeEvents = (con) => {
setImmediate(() => {
con.emit('readyForQuery')

con.emit('rowDescription', {
fields: [
{
name: 'boom',
dataTypeID: 'special oid that will throw',
},
],
suite.test('special oid that will throw', function (done) {
try {
types.setTypeParser('special oid that will throw', function () {
throw new Error('TEST: Throw in type parsers')
})

con.emit('dataRow', { fields: ['hi'] })
con.emit('dataRow', { fields: ['hi'] })
con.emit('commandComplete', { text: 'INSERT 31 1' })
con.emit('readyForQuery')
})
}

suite.test('emits error', function (done) {
var client = helper.client()
var con = client.connection
var query = client.query(new Query('whatever'))
emitFakeEvents(con)

assert.emits(query, 'error', function (err) {
assert.equal(err, typeParserError)
done()
})
})

suite.test('calls callback with error', function (done) {
var client = helper.client()
var con = client.connection
emitFakeEvents(con)
client.query('whatever', function (err) {
assert.equal(err, typeParserError)
done()
})
})

suite.test('rejects promise with error', function (done) {
var client = helper.client()
var con = client.connection
emitFakeEvents(con)
client.query('whatever').catch((err) => {
assert.equal(err, typeParserError)
assert.equal(true, false)
} catch (err) {
assert.equal(err.message, typeParserError.message)
} finally {
done()
})
}
})
Loading