Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: switch to
jsbi
for reading and writing int64
and uint64
va…
…lues
- Loading branch information
1 parent
717eb95
commit cf2a759
Showing
9 changed files
with
182 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// s2.2.7.5/6/7 | ||
const JSBI = require('jsbi'); | ||
|
||
const STATUS = { | ||
MORE: 0x0001, | ||
ERROR: 0x0002, | ||
// This bit is not yet in use by SQL Server, so is not exposed in the returned token | ||
INXACT: 0x0004, | ||
COUNT: 0x0010, | ||
ATTN: 0x0020, | ||
SRVERROR: 0x0100 | ||
}; | ||
|
||
function parseToken(parser, options, callback) { | ||
parser.readUInt16LE((status) => { | ||
const more = !!(status & STATUS.MORE); | ||
const sqlError = !!(status & STATUS.ERROR); | ||
const rowCountValid = !!(status & STATUS.COUNT); | ||
const attention = !!(status & STATUS.ATTN); | ||
const serverError = !!(status & STATUS.SRVERROR); | ||
|
||
parser.readUInt16LE((curCmd) => { | ||
const next = (rowCount) => { | ||
callback({ | ||
name: 'DONE', | ||
event: 'done', | ||
more: more, | ||
sqlError: sqlError, | ||
attention: attention, | ||
serverError: serverError, | ||
rowCount: rowCountValid ? rowCount : undefined, | ||
curCmd: curCmd | ||
}); | ||
}; | ||
|
||
if (options.tdsVersion < '7_2') { | ||
parser.readUInt32LE(next); | ||
} else { | ||
parser.readBigUInt64LE((rowCount) => { | ||
next(JSBI.toNumber(rowCount)); | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
module.exports.doneParser = doneParser; | ||
function doneParser(parser, colMetadata, options, callback) { | ||
parseToken(parser, options, (token) => { | ||
token.name = 'DONE'; | ||
token.event = 'done'; | ||
callback(token); | ||
}); | ||
} | ||
|
||
module.exports.doneInProcParser = doneInProcParser; | ||
function doneInProcParser(parser, colMetadata, options, callback) { | ||
parseToken(parser, options, (token) => { | ||
token.name = 'DONEINPROC'; | ||
token.event = 'doneInProc'; | ||
callback(token); | ||
}); | ||
} | ||
|
||
module.exports.doneProcParser = doneProcParser; | ||
function doneProcParser(parser, colMetadata, options, callback) { | ||
parseToken(parser, options, (token) => { | ||
token.name = 'DONEPROC'; | ||
token.event = 'doneProc'; | ||
callback(token); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.