Skip to content
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 lib/tedious/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ class Request extends BaseRequest {

// process batch outputs
if (batchHasOutput) {
if (!this.stream) batchLastRow = recordsets.pop()[0]
if (!this.stream) batchLastRow = recordsets.pop()?.[0]

for (const name in batchLastRow) {
const value = batchLastRow[name]
Expand Down
16 changes: 16 additions & 0 deletions test/common/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,22 @@ module.exports = (sql, driver) => {
}).catch(done)
},

'batch with output parameters and sql error' (done) {
const req = new TestRequest()
req.output('out', sql.Int)
req.batch('select * from notexistingtable').then(() => {
done(new Error('expected batch to reject with sql error'))
}).catch(err => {
try {
assert.ok(err instanceof sql.RequestError, `expected RequestError, got ${err && err.constructor.name}: ${err && err.message}`)
assert.strictEqual(err.code, 'EREQUEST')
done()
} catch (assertionError) {
done(assertionError)
}
})
},

'create procedure batch' (done) {
let req = new TestRequest()
req.batch('create procedure #temporary as select 1 as num').then(result => {
Expand Down
1 change: 1 addition & 0 deletions test/msnodesqlv8/msnodesqlv8.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe('msnodesqlv8', function () {
it('query with pipe and back pressure', (done) => TESTS['query with pipe and back pressure'](done))
it('batch', done => TESTS.batch(done))
it('batch (stream)', done => TESTS.batch(done, true))
it('batch with output parameters and sql error', done => TESTS['batch with output parameters and sql error'](done))
it('create procedure batch', done => TESTS['create procedure batch'](done))
it('prepared statement', done => TESTS['prepared statement'](done))
it('prepared statement that fails to prepare throws', done => TESTS['prepared statement that fails to prepare throws'](done))
Expand Down
1 change: 1 addition & 0 deletions test/tedious/tedious.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe('tedious', () => {
it('query with pipe and back pressure', (done) => TESTS['query with pipe and back pressure'](done))
it('query with duplicate output column names', done => TESTS['query with duplicate output column names'](done))
it('batch', done => TESTS.batch(done))
it('batch with output parameters and sql error', done => TESTS['batch with output parameters and sql error'](done))
it('create procedure batch', done => TESTS['create procedure batch'](done))
it('prepared statement', done => TESTS['prepared statement'](done))
it('prepared statement that fails to prepare throws', done => TESTS['prepared statement that fails to prepare throws'](done))
Expand Down
Loading