Transactions for SQL Server#6972
Conversation
|
@harshithkashyap, thanks for your PR! By analyzing the history of the files in this pull request, we identified @BridgeAR, @felixfbecker and @mbroadst to be potential reviewers. |
|
@felixfbecker @janmeier I've skipped a lot of tests which were timing out. By default, SQL Server blocks even select calls if the row has an exclusive lock. Most of the tests in the codebase fails as transaction is never committed/rolledback. How do you guys prefer to fix this? I'm checking if the dialect is mssql and using |
Current coverage is 94.80% (diff: 95.45%)
|
95c4706 to
59685a0
Compare
|
Well cheating the tests is not an option of course. Maybe just commit the transaction before the SELECT? |
|
But would that not cause the subsequent |
|
@mickhansen @sushantdhiman Suggestions? |
…dentifier, enabled trasaction tests for mssql dialect
8317577 to
aea2138
Compare
…s, transaction savepoints, uses sequelize_test as default database on appveyor
aea2138 to
b759355
Compare
|
@felixfbecker @janmeier SQL Server allows |
|
@harshithkashyap What do you mean with "it has to be enabled on our end"? AppVeyor is 100% configured through appveyor.yml and appveyor-setup.ps1 |
762b742 to
8c10a10
Compare
|
hm no idea, im no mssql expert |
|
@felixfbecker I've fixed it using |
|
@janmeier @sushantdhiman @felixfbecker Request review! |
janmeier
left a comment
There was a problem hiding this comment.
LGTM, good work
Out of curiousity, did you figure out why we have to call the beginTransaction et.al. methods, instead of just sending the sql command?
lib/dialects/mssql/query.js
Outdated
| }, this.options.transaction.name); | ||
| } else if (_.includes(this.sql, 'SAVE TRANSACTION')) { | ||
| connection.saveTransaction(err => { | ||
| if (!!err) { |
There was a problem hiding this comment.
unneeded boolean cast
There was a problem hiding this comment.
@felixfbecker beginTransaction, rollbackTransaction and commitTransaction also has boolean cast. Should i remove them aswell?
There was a problem hiding this comment.
Feel free to do so. The desired coding style is defined in eslintrc.json, it's just that the codebase does not fully comply with it yet.
lib/query-interface.js
Outdated
| transaction: transaction.parent || transaction | ||
| }); | ||
|
|
||
| options.transaction.name = transaction.parent ? transaction.name: undefined; |
lib/query-interface.js
Outdated
| supportsSearchPath: false | ||
| }); | ||
|
|
||
| options.transaction.name = transaction.parent ? transaction.name: undefined; |
|
@janmeier Without tedious methods, sql server throws
We use Using From the tedious docs, it seems that SQL Server will not reuse the execution plan if the same queries are executed again and again. This might add overhead to non transaction queries. |
| host: process.env.SEQ_MSSQL_HOST || process.env.SEQ_HOST || 'mssql.sequelizejs.com', | ||
| port: process.env.SEQ_MSSQL_PORT || process.env.SEQ_PORT || 1433, | ||
| dialectOptions: { | ||
| instanceName: process.env.MSSQL_INSTANCE ? process.env.MSSQL_INSTANCE : 'SQLEXPRESS', |
There was a problem hiding this comment.
Why is this not needed anymore?
There was a problem hiding this comment.
By default instance names are unnamed. I cannot connect to my local server even after specifying the server name and port. And it doesn't default to SQLEXPRESS
There was a problem hiding this comment.
Okay, was just curious. I'm not familiar with MSSQL, I just ported the thing over to AppVeyor and copied a lot from tedious PowerShell setup script.
|
Good work @harshithkashyap ! :) |
Pull Request check-list
npm run testornpm run test-DIALECTpass with this change (including linting)?Futurein the changelog?Description of change
crypto.randomBytesanduuid.v4in case of other dialects. Closes Transaction name too long for MSSQL #3950SAVE TRANSACTIONcheck to call tedious.saveTransaction method