forked from tediousjs/tedious
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqlbatch-payload.ts
37 lines (29 loc) · 990 Bytes
/
sqlbatch-payload.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import WritableTrackingBuffer from './tracking-buffer/writable-tracking-buffer';
import { writeToTrackingBuffer } from './all-headers';
/*
s2.2.6.6
*/
class SqlBatchPayload implements Iterable<Buffer> {
declare sqlText: string;
declare txnDescriptor: Buffer;
declare options: { tdsVersion: string };
constructor(sqlText: string, txnDescriptor: Buffer, options: { tdsVersion: string }) {
this.sqlText = sqlText;
this.txnDescriptor = txnDescriptor;
this.options = options;
}
*[Symbol.iterator]() {
if (this.options.tdsVersion >= '7_2') {
const buffer = new WritableTrackingBuffer(18, 'ucs2');
const outstandingRequestCount = 1;
writeToTrackingBuffer(buffer, this.txnDescriptor, outstandingRequestCount);
yield buffer.data;
}
yield Buffer.from(this.sqlText, 'ucs2');
}
toString(indent = '') {
return indent + ('SQL Batch - ' + this.sqlText);
}
}
export default SqlBatchPayload;
module.exports = SqlBatchPayload;