tedious
Version:
A TDS driver, for connecting to MS SQLServer databases.
34 lines (33 loc) • 4.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _writableTrackingBuffer = _interopRequireDefault(require("./tracking-buffer/writable-tracking-buffer"));
var _allHeaders = require("./all-headers");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/*
s2.2.6.6
*/
class SqlBatchPayload {
constructor(sqlText, txnDescriptor, options) {
this.sqlText = sqlText;
this.txnDescriptor = txnDescriptor;
this.options = options;
}
*[Symbol.iterator]() {
if (this.options.tdsVersion >= '7_2') {
const buffer = new _writableTrackingBuffer.default(18, 'ucs2');
const outstandingRequestCount = 1;
(0, _allHeaders.writeToTrackingBuffer)(buffer, this.txnDescriptor, outstandingRequestCount);
yield buffer.data;
}
yield Buffer.from(this.sqlText, 'ucs2');
}
toString(indent = '') {
return indent + ('SQL Batch - ' + this.sqlText);
}
}
var _default = exports.default = SqlBatchPayload;
module.exports = SqlBatchPayload;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfd3JpdGFibGVUcmFja2luZ0J1ZmZlciIsIl9pbnRlcm9wUmVxdWlyZURlZmF1bHQiLCJyZXF1aXJlIiwiX2FsbEhlYWRlcnMiLCJlIiwiX19lc01vZHVsZSIsImRlZmF1bHQiLCJTcWxCYXRjaFBheWxvYWQiLCJjb25zdHJ1Y3RvciIsInNxbFRleHQiLCJ0eG5EZXNjcmlwdG9yIiwib3B0aW9ucyIsIlN5bWJvbCIsIml0ZXJhdG9yIiwidGRzVmVyc2lvbiIsImJ1ZmZlciIsIldyaXRhYmxlVHJhY2tpbmdCdWZmZXIiLCJvdXRzdGFuZGluZ1JlcXVlc3RDb3VudCIsIndyaXRlVG9UcmFja2luZ0J1ZmZlciIsImRhdGEiLCJCdWZmZXIiLCJmcm9tIiwidG9TdHJpbmciLCJpbmRlbnQiLCJfZGVmYXVsdCIsImV4cG9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