diff --git a/packages/pg/lib/query.js b/packages/pg/lib/query.js index 0925960e6..fbef341bf 100644 --- a/packages/pg/lib/query.js +++ b/packages/pg/lib/query.js @@ -65,7 +65,7 @@ class Query extends EventEmitter { if (!Array.isArray(this._results)) { this._results = [this._result] } - this._result = new Result(this._rowMode, this.types) + this._result = new Result(this._rowMode, this._result._types) this._results.push(this._result) } } diff --git a/packages/pg/test/integration/client/custom-types-tests.js b/packages/pg/test/integration/client/custom-types-tests.js index b3446cff0..eb5fa892c 100644 --- a/packages/pg/test/integration/client/custom-types-tests.js +++ b/packages/pg/test/integration/client/custom-types-tests.js @@ -22,6 +22,21 @@ suite.test('custom type parser in client config', (done) => { }) }) +suite.test('custom type parser in client config with multiple results', (done) => { + const client = new Client({ types: customTypes }) + + client.connect().then(() => { + client.query( + `SELECT 'foo'::text as name; SELECT 'bar'::text as baz`, + assert.success(function (res) { + assert.equal(res[0].rows[0].name, 'okay!') + assert.equal(res[1].rows[0].baz, 'okay!') + client.end().then(done) + }) + ) + }) +}) + // Custom type-parsers per query are not supported in native if (!helper.args.native) { suite.test('custom type parser in query', (done) => {