Repository navigation
Ability to do use table hints per query with MSSQL - #8843
Conversation
…ll value produces wrong SQL issue 8816
…th comparator, this is catching fix issue sequelize#8816
…ult values. Failing tests to sh issue sequelize#8814
… default values, when provided, issue sequelize#8814
| mainFragment += ' AS ' + mainTableAs; | ||
| } | ||
|
|
||
| const tableHints = ['NOLOCK', 'READUNCOMMITTED', 'UPDLOCK', 'REPEATABLEREAD', 'SERIALIZABLE', 'READCOMMITTED', 'TABLOCK', 'TABLOCKX', 'PAGLOCK', 'ROWLOCK', 'NOWAIT', 'READPAST', 'XLOCK', 'SNAPSHOT', 'NOEXPAND']; |
There was a problem hiding this comment.
Since we are hard coding the available values anyway, we might as well expose it as an object, similar to datatypes. That way users can also get editor completion
https://github.com/mccabemj/sequelize/blob/ca4d995f80d5ca22563061adb3ea51aed0852094/lib/sequelize.js#L1165
https://github.com/mccabemj/sequelize/blob/ca4d995f80d5ca22563061adb3ea51aed0852094/lib/query-types.js
There was a problem hiding this comment.
Thanks @janmeier good suggestion. I have implemented that, let me know what you think
…nts available for mssql queries issue sequelize#8830
sushantdhiman
left a comment
There was a problem hiding this comment.
Implementation looks good, I found a feature request #7031
It seems there can be multiple hints on single table, so tableHints should be an array possibly.
I haven't used MSSQL table hints so not sure but if its possible we should support multiple hints too.
Got it, lets start with small if there is demand for multiple hints we can always add that later |
|
@sushantdhiman yes, I was aiming to start small. In the future, a new option could be added for multiples, but this would be a lot more complex as it would have to allow for indexs on certain values. Plus, you are not allowed more than one hint from each group (Granularity hints and Isolation level hints) so that would have to be coded. Seeing as there is only my issue and #7031 I'd say this is good enough for now. Your call |
Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
As per issue #8830 I have implemented the ability to do table hints with MSSQL queries. Simply adding the
tableHintoption with a string containing the type of table hint will add it to the SQL of the query. I have also added tests for a couple of potential table hints.The array of potential table hints comes from the
table_hint_limitedsection herehttps://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-table
Note I have not added the ability for multiple table hints, or the ability to use hints with index's. This could be added in the future.