Skip to content

fix: use existing Result types for new Result #3310

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

Merged
merged 3 commits into from
Oct 23, 2024
Merged
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/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