Skip to content

Commit

Permalink
fix: use existing Result types for new Result (#3310)
Browse files Browse the repository at this point in the history
* fix: use existing Result types for new Result

* test: add test for multiple results with custom type parser

* chore: empty commit to trigger tests
  • Loading branch information
mantariksh authored Oct 23, 2024
1 parent 8b2768f commit 1af6321
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/pg/lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
15 changes: 15 additions & 0 deletions packages/pg/test/integration/client/custom-types-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 1af6321

Please sign in to comment.