mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
Result.fields should always be an array (#2060)
This fixes a subtle backwards incompatible change. Added a test to prevent further regressions. Closes #2056
This commit is contained in:
parent
8eca181d20
commit
19308f9ceb
@ -17,7 +17,7 @@ var Result = function (rowMode, types) {
|
||||
this.rowCount = null
|
||||
this.oid = null
|
||||
this.rows = []
|
||||
this.fields = undefined
|
||||
this.fields = []
|
||||
this._parsers = undefined
|
||||
this._types = types
|
||||
this.RowCtor = null
|
||||
|
||||
22
packages/pg/test/integration/gh-issues/2056-tests.js
Normal file
22
packages/pg/test/integration/gh-issues/2056-tests.js
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
"use strict"
|
||||
var helper = require('./../test-helper')
|
||||
var assert = require('assert')
|
||||
|
||||
const suite = new helper.Suite()
|
||||
|
||||
suite.test('All queries should return a result array', (done) => {
|
||||
const client = new helper.pg.Client()
|
||||
client.connect()
|
||||
const promises = []
|
||||
promises.push(client.query('CREATE TEMP TABLE foo(bar TEXT)'))
|
||||
promises.push(client.query('INSERT INTO foo(bar) VALUES($1)', ['qux']))
|
||||
promises.push(client.query('SELECT * FROM foo WHERE bar = $1', ['foo']))
|
||||
Promise.all(promises).then(results => {
|
||||
results.forEach(res => {
|
||||
assert(Array.isArray(res.fields))
|
||||
assert(Array.isArray(res.rows))
|
||||
})
|
||||
client.end(done)
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user