Skip to content

Add allow_nil option for IS NULL filtering on non-JSONB types#84

Open
raafatalaa wants to merge 1 commit into
procore-oss:mainfrom
raafatalaa:add-null-filter-support
Open

Add allow_nil option for IS NULL filtering on non-JSONB types#84
raafatalaa wants to merge 1 commit into
procore-oss:mainfrom
raafatalaa:add-null-filter-support

Conversation

@raafatalaa

@raafatalaa raafatalaa commented Jun 17, 2026

Copy link
Copy Markdown

Summary

  • Adds an allow_nil: true option to filter_on that enables IS NULL filtering for non-JSONB column types
  • When enabled, passing the string "null" as a filter value produces WHERE col IS NULL
  • Combining "null" with real values (e.g. ["null", "5"]) produces WHERE col IS NULL OR col IN (5)
  • Filters without allow_nil: true are unaffected — existing behavior is fully preserved

Usage

filter_on :assignee_id, type: :int, allow_nil: true
GET /posts?filters[assignee_id]=null
GET /posts?filters[assignee_id][]=null&filters[assignee_id][]=5

Closes #81

Test plan

  • filters[col]=null with allow_nil: trueWHERE col IS NULL
  • filters[col]=NULL (uppercase) with allow_nil: true → same behavior
  • filters[col][]=null&filters[col][]=5 with allow_nil: trueWHERE col IS NULL OR col IN (5)
  • filters[col]=null on a string column with allow_nil: trueWHERE col IS NULL
  • filters[col]=null without allow_nil → returns 400 validation error (for int type)
  • Non-null filters still work identically (regression check)
  • All existing unit tests pass

@raafatalaa raafatalaa requested a review from a team as a code owner June 17, 2026 17:57
@raafatalaa raafatalaa force-pushed the add-null-filter-support branch 2 times, most recently from d1a1dea to 438596e Compare June 17, 2026 18:17
Consumers can now opt in to null filtering by declaring
`filter_on :col, type: :int, allow_nil: true`. When enabled,
passing the string "null" as a filter value produces
`WHERE col IS NULL`, and combining it with real values
(e.g. `["null", "5"]`) produces `WHERE col IS NULL OR col IN (5)`.

Filters without `allow_nil: true` are unaffected — the existing
behavior is fully preserved.

Closes procore-oss#81

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: raafatalaa <raafat.alaa@procore.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: raafatalaa <raafat.alaa@procore.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@raafatalaa raafatalaa force-pushed the add-null-filter-support branch from 438596e to c0ba0e9 Compare June 22, 2026 19:02
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.

Support nil/IS NULL filtering for non-JSONB attributes

3 participants