Skip to content

Commit 1af6321

Browse files
authored
fix: use existing Result types for new Result (brianc#3310)
* fix: use existing Result types for new Result * test: add test for multiple results with custom type parser * chore: empty commit to trigger tests
1 parent 8b2768f commit 1af6321

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

packages/pg/lib/query.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Query extends EventEmitter {
6565
if (!Array.isArray(this._results)) {
6666
this._results = [this._result]
6767
}
68-
this._result = new Result(this._rowMode, this.types)
68+
this._result = new Result(this._rowMode, this._result._types)
6969
this._results.push(this._result)
7070
}
7171
}

packages/pg/test/integration/client/custom-types-tests.js

+15
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ suite.test('custom type parser in client config', (done) => {
2222
})
2323
})
2424

25+
suite.test('custom type parser in client config with multiple results', (done) => {
26+
const client = new Client({ types: customTypes })
27+
28+
client.connect().then(() => {
29+
client.query(
30+
`SELECT 'foo'::text as name; SELECT 'bar'::text as baz`,
31+
assert.success(function (res) {
32+
assert.equal(res[0].rows[0].name, 'okay!')
33+
assert.equal(res[1].rows[0].baz, 'okay!')
34+
client.end().then(done)
35+
})
36+
)
37+
})
38+
})
39+
2540
// Custom type-parsers per query are not supported in native
2641
if (!helper.args.native) {
2742
suite.test('custom type parser in query', (done) => {

0 commit comments

Comments
 (0)