Repository navigation
Closed
Labels
dialect: mssqlFor issues and PRs. Things that involve MSSQL (and do not involve all dialects).type: bugDEPRECATED: replace with the "bug" issue type
Description
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:
sequelize/lib/dialects/mssql/query.js
Lines 47 to 71 in 7d597ef
| 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
Metadata
Metadata
Assignees
Labels
dialect: mssqlFor issues and PRs. Things that involve MSSQL (and do not involve all dialects).type: bugDEPRECATED: replace with the "bug" issue type
Activity
Replaced lodash includes with startsWith, review fixes, closes sequel…