[Mssql] Fix empty inArray/notInArray using invalid true/false in T-SQL#5956
Open
Vishal-770 wants to merge 1 commit into
Open
[Mssql] Fix empty inArray/notInArray using invalid true/false in T-SQL#5956Vishal-770 wants to merge 1 commit into
Vishal-770 wants to merge 1 commit into
Conversation
3db7019 to
8182875
Compare
…Array T-SQL has no true/false keywords, so inArray(col, []) and notInArray(col, []) generated invalid SQL on the mssql driver. This overrides the shared implementations in mssql-core/expressions.ts, following the same per-dialect override pattern already used there for concat() and substring(). Fixes drizzle-team#5632
8182875 to
730d0a9
Compare
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.
Problem
inArray(column, [])andnotInArray(column, [])render assqlfalse/ `sql`truein the shared expression code(
sql/expressions/conditions.ts). This is correct for Postgres,MySQL, and SQLite, but T-SQL has no
true/falsekeywords, sothese queries fail on the mssql driver.
Fix
Override
inArray/notInArrayinmssql-core/expressions.tsto use1 = 0(always false) and1 = 1(always true) for the empty-arraycase, while leaving every other dialect untouched. This follows the
same per-dialect override pattern already used in this file for
concat()andsubstring().Testing
integration-tests/tests/mssql/mssql.test.tscovering
inArray/notInArraywith an empty array.tsc --noEmitintroduces no new type errors.Fixes #5632