Skip to content

Add 'in' filter operator to card query language#4290

Merged
lukemelia merged 4 commits into
mainfrom
cs-10561-add-in-filter-operator-to-card-query-language
Apr 1, 2026
Merged

Add 'in' filter operator to card query language#4290
lukemelia merged 4 commits into
mainfrom
cs-10561-add-in-filter-operator-to-card-query-language

Conversation

@lukemelia
Copy link
Copy Markdown
Contributor

@lukemelia lukemelia commented Mar 31, 2026

Summary

  • Adds a new in filter operator to the card query language for concise set membership queries
  • Replaces verbose any + eq workaround: { in: { id: ['id1', 'id2'] } } instead of { any: [{ eq: { id: 'id1' } }, { eq: { id: 'id2' } }] }
  • Handles empty arrays (matches nothing), null values (OR'd with IS NULL), and nested field paths
  • Supports interpolation from containsMany fields in query-backed fields (e.g. { in: { tag: '$this.tags' } })

Closes CS-10561

Changes

  • packages/runtime-common/query.tsInFilter type, isInFilter() guard, assertInFilter() validation
  • packages/runtime-common/index-query-engine.tsinCondition() and fieldInFilter() SQL generation
  • packages/runtime-common/query-field-utils.ts — Added in to EMPTY_PREDICATE_KEYS for query abort on undefined
  • packages/host/tests/unit/index-query-engine-test.ts — 6 query engine test cases
  • packages/host/tests/unit/query-field-normalization-test.ts — 2 interpolation test cases
  • packages/software-factory/.agents/skills/boxel-development/references/dev-query-systems.md — Added in to documented filter types

Test plan

  • Basic in with multiple values
  • Single value in array
  • Empty array matches nothing
  • Null value handling
  • Nested field paths (address.city)
  • Negation with not: { in: ... }
  • Array interpolation from containsMany field resolves correctly
  • Undefined containsMany field aborts query gracefully
  • CI passes

🤖 Generated with Claude Code

@lukemelia lukemelia force-pushed the cs-10561-add-in-filter-operator-to-card-query-language branch from 97400d0 to 161aaf3 Compare March 31, 2026 17:49
@lukemelia lukemelia marked this pull request as ready for review March 31, 2026 17:50
@lukemelia lukemelia requested a review from Copilot March 31, 2026 17:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new in filter operator to the card query language, enabling concise set-membership queries and supporting normalization/interpolation use cases for query-backed fields.

Changes:

  • Introduces InFilter to the runtime-common query types/validation and documents it in the internal dev reference.
  • Adds SQL generation support for in filters in the index query engine, including empty-list and null-value behavior.
  • Expands query-field normalization + engine unit tests to cover in behavior and interpolation scenarios.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/software-factory/.agents/skills/boxel-development/references/dev-query-systems.md Documents in as a filter type that requires on.
packages/runtime-common/query.ts Adds InFilter type, guard, and query validation (assertInFilter).
packages/runtime-common/query-field-utils.ts Treats in as an “empty predicate” key for abort-on-undefined interpolation behavior.
packages/runtime-common/index-query-engine.ts Generates SQL conditions for in filters (inCondition, fieldInFilter).
packages/host/tests/unit/index-query-engine-test.ts Adds unit tests for in filter semantics (multi, single, empty, null, nested, negation).
packages/host/tests/unit/query-field-normalization-test.ts Adds tests for in filter interpolation from containsMany and abort behavior on undefined.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/runtime-common/query.ts Outdated
Comment thread packages/runtime-common/query.ts Outdated
Comment thread packages/runtime-common/index-query-engine.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

Preview deployments

@lukemelia lukemelia force-pushed the cs-10561-add-in-filter-operator-to-card-query-language branch from 161aaf3 to 73223ab Compare March 31, 2026 18:07
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 31, 2026

Realm Server Test Results

  1 files  ±0    1 suites  ±0   12m 11s ⏱️ +4s
811 tests +9  811 ✅ +9  0 💤 ±0  0 ❌ ±0 
882 runs  +9  882 ✅ +9  0 💤 ±0  0 ❌ ±0 

Results for commit 73cd257. ± Comparison against base commit 20a185a.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 31, 2026

Host Test Results

    1 files  ±0      1 suites  ±0   2h 10m 41s ⏱️ - 3m 43s
2 071 tests +9  2 056 ✅ +9  15 💤 ±0  0 ❌ ±0 
2 086 runs  +9  2 071 ✅ +9  15 💤 ±0  0 ❌ ±0 

Results for commit 73cd257. ± Comparison against base commit 20a185a.

♻️ This comment has been updated with latest results.

Adds a new `in` filter that checks if a field value is in a specified set,
replacing the verbose `any` + `eq` workaround for set membership queries.

Handles empty arrays (matches nothing), null values, and nested field paths.
Supports interpolation from containsMany fields in query-backed fields.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lukemelia lukemelia force-pushed the cs-10561-add-in-filter-operator-to-card-query-language branch from 73223ab to cef914f Compare March 31, 2026 18:36
@lukemelia lukemelia requested review from a team, habdelra and tintinthong March 31, 2026 18:37
@habdelra
Copy link
Copy Markdown
Contributor

habdelra commented Mar 31, 2026

you are going to need both realm server and host tests. the host test will only test sqlite implementation, the realm server tests will test postgres implementation. i don't see realm server tests

Luke Melia added 3 commits March 31, 2026 22:20
Tests the 'in' filter via the _search HTTP endpoint against a postgres
database, complementing the existing host tests that cover SQLite.

Covers: multiple values, single value, empty array, null values,
different fields, and negation with 'not'.
Covers filtering cards by id with the 'in' operator in both
host (SQLite) and realm-server (Postgres) test suites.
@lukemelia lukemelia merged commit 417c292 into main Apr 1, 2026
57 checks passed
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.

3 participants