Skip to content

Expand an empty slice in In to NULL instead of returning an error. - #22

Merged
avgvi merged 1 commit into
masterfrom
fix/945-in-empty-slice
Oct 11, 2026
Merged

avgvi merged 1 commit into
masterfrom
fix/945-in-empty-slice

Conversation

@avgvi

@avgvi avgvi commented Oct 11, 2026

Copy link
Copy Markdown
Member

An empty or nil slice passed to In now expands to the SQL literal NULL and binds no argument, so x IN (?) becomes x IN (NULL), which matches no row. NULL is the only fragment that is valid and type-safe inside the parentheses on Postgres 16, MySQL 8.4, SQLite, SQL Server 2022 and Oracle 23 (an untyped empty subquery fails on Postgres for non-text columns). x NOT IN (?) becomes x NOT IN (NULL), which also matches no row by SQL three-valued logic; the doc comment says so and an integration case pins it. Answers upstream #945, whose own change bound nil to the placeholder rather than emitting IN ().

Callers that used the old error as an empty-list guard must check the length themselves; this gets a changelog line. The two error-table cases in the existing tests are removed; a 17-case table test and integration cases on all three databases are added.

Local run with Postgres 16, MySQL 8.4 and SQLite: 106 pass, 3 skip, 0 fail.

@avgvi
avgvi merged commit 3c20862 into master Oct 11, 2026
6 checks passed
@avgvi
avgvi deleted the fix/945-in-empty-slice branch October 11, 2026 04:28
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