Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Switch from function() style to => in transaction method call… #465

Merged
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
40 changes: 22 additions & 18 deletions src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,12 +728,13 @@ class Connection extends EventEmitter {
isolationLevel || (isolationLevel = this.config.options.isolationLevel);
const transaction = new Transaction(name || '', isolationLevel);
if (this.config.options.tdsVersion < '7_2') {
return this.execSqlBatch(new Request('SET TRANSACTION ISOLATION LEVEL ' + (transaction.isolationLevelToTSQL()) + ';BEGIN TRAN ' + transaction.name, (...args) => {
this.transactionDepth++;
if (this.transactionDepth === 1) {
this.inTransaction = true;
const self = this;
return this.execSqlBatch(new Request('SET TRANSACTION ISOLATION LEVEL ' + (transaction.isolationLevelToTSQL()) + ';BEGIN TRAN ' + transaction.name, function() {
self.transactionDepth++;
if (self.transactionDepth === 1) {
self.inTransaction = true;
}
return callback.apply(null, args);
return callback.apply(null, arguments);
}));
}

Expand All @@ -746,12 +747,13 @@ class Connection extends EventEmitter {
commitTransaction(callback, name) {
const transaction = new Transaction(name || '');
if (this.config.options.tdsVersion < '7_2') {
return this.execSqlBatch(new Request('COMMIT TRAN ' + transaction.name, (...args) => {
this.transactionDepth--;
if (this.transactionDepth === 0) {
this.inTransaction = false;
const self = this;
return this.execSqlBatch(new Request('COMMIT TRAN ' + transaction.name, function() {
self.transactionDepth--;
if (self.transactionDepth === 0) {
self.inTransaction = false;
}
return callback.apply(null, args);
return callback.apply(null, arguments);
}));
}
const request = new Request(void 0, callback);
Expand All @@ -761,12 +763,13 @@ class Connection extends EventEmitter {
rollbackTransaction(callback, name) {
const transaction = new Transaction(name || '');
if (this.config.options.tdsVersion < '7_2') {
return this.execSqlBatch(new Request('ROLLBACK TRAN ' + transaction.name, (...args) => {
this.transactionDepth--;
if (this.transactionDepth === 0) {
this.inTransaction = false;
const self = this;
return this.execSqlBatch(new Request('ROLLBACK TRAN ' + transaction.name, function() {
self.transactionDepth--;
if (self.transactionDepth === 0) {
self.inTransaction = false;
}
return callback.apply(null, args);
return callback.apply(null, arguments);
}));
}
const request = new Request(void 0, callback);
Expand All @@ -776,9 +779,10 @@ class Connection extends EventEmitter {
saveTransaction(callback, name) {
const transaction = new Transaction(name);
if (this.config.options.tdsVersion < '7_2') {
return this.execSqlBatch(new Request('SAVE TRAN ' + transaction.name, (...args) => {
this.transactionDepth++;
return callback.apply(null, args);
const self = this;
return this.execSqlBatch(new Request('SAVE TRAN ' + transaction.name, function() {
self.transactionDepth++;
return callback.apply(null, arguments);
}));
}
const request = new Request(void 0, callback);
Expand Down