Skip to content

Add tag filtering to JobListParams - #1339

Open
bgentry wants to merge 2 commits into
masterfrom
bg/job-list-tags
Open

Add tag filtering to JobListParams#1339
bgentry wants to merge 2 commits into
masterfrom
bg/job-list-tags

Conversation

@bgentry

@bgentry bgentry commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Adds exact tag filtering to job lists through explicit JobListParams.TagsAny
and JobListParams.TagsAll methods. The two filters can be combined, with
match-any and match-all groups joined to each other and other filters using
AND.

Tag predicates are added only when requested through driver-specific SQL
fragments. PostgreSQL uses native array overlap and containment operators,
while SQLite uses equivalent JSON predicates. JobDeleteManyParams is defined
from the list parameter type so their existing pointer conversion remains
structurally safe.

This is the core dependency for
riverqueue/riverui#548.

bgentry added a commit to golanglemonade/riverui that referenced this pull request Aug 2, 2026
The job-list endpoint currently implements tag matching with PostgreSQL-only
SQL through `JobListParams.Where`, preventing the handler from working with
other River drivers.

Pin River to the commit from riverqueue/river#1339 and call the new
`JobListParams.Tags` method. River now owns the case-insensitive, match-any
query semantics for PostgreSQL and SQLite, while RiverUI remains independent
of driver-specific SQL.
@bgentry
bgentry marked this pull request as ready for review August 2, 2026 00:02
@bgentry
bgentry requested a review from brandur August 2, 2026 00:02
Comment thread client.go Outdated
}

jobs, err := exec.JobDeleteMany(ctx, (*riverdriver.JobDeleteManyParams)(listParams))
jobs, err := exec.JobDeleteMany(ctx, &riverdriver.JobDeleteManyParams{

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ah this needs to be kept aligned with list params, will fix

Applications that need to find jobs by tag currently have to use a
driver-specific `Where` predicate. That prevents shared consumers from
supporting PostgreSQL and SQLite with the same list query.

Add `JobListParams.Tags` with case-insensitive, match-any semantics and
carry it through each driver. PostgreSQL compares unnested arrays, while
SQLite compares the equivalent JSON array values.

Keep the list and delete-many driver parameter layouts synchronized so the
existing pointer conversion remains valid. Add shared driver coverage for
combined filters, transactions, and tag matching across every supported
driver.
bgentry added a commit to golanglemonade/riverui that referenced this pull request Aug 2, 2026
The job-list endpoint currently implements tag matching with PostgreSQL-only
SQL through `JobListParams.Where`, preventing the handler from working with
other River drivers.

Pin River to the commit from riverqueue/river#1339 and call the new
`JobListParams.Tags` method. River now owns the case-insensitive, match-any
query semantics for PostgreSQL and SQLite, while RiverUI remains independent
of driver-specific SQL.
Comment thread job_list_params.go Outdated
}

// Tags returns an updated filter set that will only return jobs containing at
// least one of the given tags. Tag matching is case-insensitive.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@brandur while this copies what the other PR does, it doesn't feel right now that I read this comment. Wondering if we need two separate methods for filtering by all of vs any of the tags in the list?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like you put in the two separate functions and this comment is outdated. Looks okay as is.

The tag list filter exposes match-any behavior through an ambiguous method
name and folds case even though River preserves tag spelling. Its static SQL
also adds work to every list query and prevents PostgreSQL from using native
array operators.

Replace it with exact TagsAny and TagsAll filters. Build their predicates
only when requested through driver-specific fragments, using PostgreSQL
overlap and containment operators and equivalent SQLite JSON predicates.
Define delete parameters from list parameters so their pointer conversion
stays structurally safe.

Expand shared driver coverage for any, all, combined, case-sensitive, empty,
pagination, transaction, and low-level fragment behavior.

@brandur brandur left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice one! Looks good to me.

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.

2 participants