Skip to content

[Mssql] Fix empty inArray/notInArray using invalid true/false in T-SQL#5956

Open
Vishal-770 wants to merge 1 commit into
drizzle-team:betafrom
Vishal-770:fix/mssql-empty-array-inarray
Open

[Mssql] Fix empty inArray/notInArray using invalid true/false in T-SQL#5956
Vishal-770 wants to merge 1 commit into
drizzle-team:betafrom
Vishal-770:fix/mssql-empty-array-inarray

Conversation

@Vishal-770

@Vishal-770 Vishal-770 commented Jun 29, 2026

Copy link
Copy Markdown

Problem

inArray(column, []) and notInArray(column, []) render as
sqlfalse / `sql`true in the shared expression code
(sql/expressions/conditions.ts). This is correct for Postgres,
MySQL, and SQLite, but T-SQL has no true/false keywords, so
these queries fail on the mssql driver.

Fix

Override inArray/notInArray in mssql-core/expressions.ts to use
1 = 0 (always false) and 1 = 1 (always true) for the empty-array
case, while leaving every other dialect untouched. This follows the
same per-dialect override pattern already used in this file for
concat() and substring().

Testing

  • Added integration tests in integration-tests/tests/mssql/mssql.test.ts
    covering inArray/notInArray with an empty array.
  • Verified tsc --noEmit introduces no new type errors.

Fixes #5632

@Vishal-770 Vishal-770 force-pushed the fix/mssql-empty-array-inarray branch from 3db7019 to 8182875 Compare June 29, 2026 05:29
…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
@Vishal-770 Vishal-770 force-pushed the fix/mssql-empty-array-inarray branch from 8182875 to 730d0a9 Compare June 29, 2026 05:31
@Vishal-770 Vishal-770 changed the title fix(mssql): empty inArray/notInArray use 1=0/1=1 instead of true/false [Mssql] Fix empty inArray/notInArray using invalid true/false in T-SQL Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant