Skip to content

Commit bd8a2dd

Browse files
committed
[CONJS-128] error when using multipleStatements with metaAsArray #106
1 parent a0551d8 commit bd8a2dd

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

lib/cmd/resultset.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,10 @@ class ResultSet extends Command {
396396
// [ {"1": 1} ], //rows
397397
// [ColumnDefinition] //meta
398398
// ]
399-
if (this._responseIndex === 0) this._meta = [];
399+
if (!this._meta) {
400+
this._meta = new Array(this._responseIndex);
401+
}
402+
400403
this._meta[this._responseIndex] = this._columns;
401404

402405
if (info.status & ServerStatus.MORE_RESULTS_EXISTS || this.isOutParameter) {

test/integration/test-pool.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,35 @@ describe('Pool', () => {
1616
//eat
1717
});
1818
});
19+
20+
it('pool metaAsArray', function(done) {
21+
const pool = base.createPool({
22+
metaAsArray: true,
23+
multipleStatements: true,
24+
connectionLimit: 1
25+
});
26+
pool
27+
.query({
28+
sql:
29+
'DROP TABLE IF EXISTS t; ' +
30+
'CREATE TABLE t (i int);\n' +
31+
'INSERT INTO t(i) VALUES (1);\n' +
32+
'SELECT i FROM t; ',
33+
timeout: 3000
34+
})
35+
.then(res => {
36+
assert.equal(2, res.length);
37+
assert.equal(4, res[0].length);
38+
assert.equal(4, res[1].length);
39+
assert.equal('i', res[1][3][0].name());
40+
pool.end();
41+
done();
42+
})
43+
.catch(err => {
44+
pool.end();
45+
done(err);
46+
});
47+
});
1948

2049
it('pool escape', function() {
2150
if (!base.utf8Collation()) this.skip();

0 commit comments

Comments
 (0)