[MsSql] Add WITH (NOLOCK) table hint support to select query builder#5884
Open
valerii-kuzivanov wants to merge 1 commit into
Open
[MsSql] Add WITH (NOLOCK) table hint support to select query builder#5884valerii-kuzivanov wants to merge 1 commit into
valerii-kuzivanov wants to merge 1 commit into
Conversation
Adds an optional table hint config to .from() and all join methods
({ withNoLock: true }), plus a chainable .withNoLock() method that
applies the hint to the main table and every joined table at once.
Follows the same pattern as MySQL index hints (useIndex/forceIndex):
hints are accepted only for MsSqlTable sources, rejected at the type
level for subqueries, views and raw SQL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5883
Adds
WITH (NOLOCK)table hint support to the MSSQL select query builder, following the same pattern as the MySQL index hints (useIndex/forceIndex/ignoreIndex).API
Per-table hint config on
.from()and all join methods:Chainable
.withNoLock()that applies the hint to the main table and every joined table (order-independent — it works regardless of whether joins are added before or after the call):Both produce:
Implementation notes
MsSqlTableHintConfig({ withNoLock?: boolean }) is accepted only forMsSqlTablesources; subqueries, views and raw SQL are rejected at the type level with the same error-string-literal technique the MySQL index hints use.MsSqlSelectConfig(withNoLock,allWithNoLock) andMsSqlSelectJoinConfig(withNoLock), emitted inMsSqlDialect.buildSelectQueryright after the table identifier/alias.withNoLockis added toMsSqlSetOperatorExcludedMethods.READPAST,UPDLOCK, …) without an API break.Tests
type-tests/mssql/select.ts: valid usage on tables and joins,@ts-expect-errorfor views/subqueries/unknown hint keys,.withNoLock()chaining —pnpm test:typespasses.integration-tests/tests/mssql/mssql.test.ts: threetoSQL()query checks (from-hint, join-hint,.withNoLock()all-tables) plus one execution test against a real SQL Server (azure-sql-edge) instance.tests/mssql/mssql.test.ts(162 passed / 1 pre-existing skip) andtests/mssql/mssql.rels.test.ts(88 passed) are green.