Skip to content

MSSQL Cannot save string with the text 'COMMIT TRANSACTION' #6954

Closed

Description

@coolhome

What you are doing?

Trying to create or update a record that has a string column with the value "COMMIT TRANSACTION".

Using the documentation model Task the following code will error with:

The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
Task.create({ title: 'COMMIT TRANSACTION', description: 'bar', deadline: new Date() });
Task.create({ title: 'BEGIN TRANSACTION', description: 'bar', deadline: new Date() });
Task.create({ title: 'ROLLBACK TRANSACTION', description: 'bar', deadline: new Date() });

What do you expect to happen?

I expect Task to be created in the database where with the title being 'COMMIT TRANSACTION'

What is actually happening?

It is trying to either commit, begin, or roll back a transaction.

Root cause in source code:

if (_.includes(this.sql, 'BEGIN TRANSACTION')) {
connection.beginTransaction(err => {
if (!!err) {
reject(this.formatError(err));
} else {
resolve(this.formatResults());
}
} /* name, isolation_level */);
} else if (_.includes(this.sql, 'COMMIT TRANSACTION')) {
connection.commitTransaction(err => {
if (!!err) {
reject(this.formatError(err));
} else {
resolve(this.formatResults());
}
});
} else if (_.includes(this.sql, 'ROLLBACK TRANSACTION')) {
connection.rollbackTransaction(err => {
if (!!err) {
reject(this.formatError(err));
} else {
resolve(this.formatResults());
}
});
} else {

Introduced by:
99abdc3

Dialect: mssql
Database version: SQL Server 2016
Sequelize version: 3.27.0

Activity

  1. added
    type: bug
    on Dec 6, 2016
  2. added
    dialect: mssql
    on Dec 7, 2016
  3. added a commit that references this issue on Dec 20, 2016
    28fce11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dialect: mssqltype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions