Skip to content

feat(analysis): bind column = ANY placeholders as typed lists - #60

Merged
omer-cengel merged 2 commits into
masterfrom
feature/any-list-predicates
Oct 4, 2026
Merged

omer-cengel merged 2 commits into
masterfrom
feature/any-list-predicates

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

Queries can now filter by a list of values with PostgreSQL's column = ANY($1), the idiomatic alternative to dynamic IN expansion. The placeholder becomes one List<T> method parameter of the compared column's type, bound as a single server array, so WHERE id = ANY($1) generates List<Long> id.

Changes

  • WHERE clauses of SELECT, UPDATE, and DELETE accept <column> = ANY(<placeholder>) with a $N or :name placeholder; the parameter is a list of the column's type, carrying its enum type and blank-padded spelling, and is named after the column (a named placeholder keeps its own name).
  • One named list used in several predicates, such as id = ANY(:ids) OR parent_id = ANY(:ids), is one parameter bound at every position; using the same name as both a list and a scalar is rejected as conflicting types.
  • A cast argument such as ANY($1::bigint[]), ANY(CAST($1 AS bigint[])), or ANY(:ids::bigint[]) stays typed by its cast and is now named after the compared column.
  • A list over an array column or a BYTEA, JSON, or JSONB column is rejected with a clear message; the array element-type rule is shared with schema parsing rather than duplicated.
  • Analyzer, generated-source compilation, and PostgreSQL tests cover null, empty, one-element, several-element, and enum-column lists.
  • Query and PostgreSQL documentation describe the predicate, its naming, and its rejections.

Scope and non-goals

  • Only = with the column on the left and an unquoted, unqualified ANY around exactly one placeholder is analyzed; <> ANY, SOME/ALL, ANY($1) = id, ARRAY[...] arguments, modifiers, and multiple arguments keep the existing unanalyzed-placeholder rejection.
  • A cast argument's type is not checked against the compared column.
  • No change to SQL parameter compilation, code generation, or the runtime; no IN list expansion; ANY is not analyzed in projections, ON, HAVING, or write values.

@omer-cengel
omer-cengel merged commit 7087c48 into master Oct 4, 2026
6 checks passed
@omer-cengel
omer-cengel deleted the feature/any-list-predicates branch October 4, 2026 20:10
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