Skip to content

GH-5296 Query saga instances by saga type: filters, ordering, paging and counts - #5301

Merged
jeremydmiller merged 1 commit into
mainfrom
stoat/critterwatch-1-2/wolverine-saga-query
Oct 30, 2026
Merged

jeremydmiller merged 1 commit into
mainfrom
stoat/critterwatch-1-2/wolverine-saga-query

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Fixes #5296

Adds ISagaStoreDiagnostics.QuerySagasAsync(sagaTypeName, DocumentQueryOptions, ct) returning SagaQueryResult (page + total count), and GetQueryCapabilities(sagaTypeName) so a UI knows up front what a storage can do. Both are default-implemented, so older storages still load. The aggregator routes by saga type.

Shared rules live in SagaQueryCriteria: page size clamped to 1000, unordered queries ordered by identity, unsupported criteria (IdEquals, metadata filters, tenant) and any Where/OrderBy a storage cannot honour throw DocumentCriteriaNotSupportedException, never an unfiltered page. AOT reports paging-only.

Storage Result
Marten filter, order, page, count via ApplyCriteriaTo (tested against Postgres)
EF Core same via Set<T>().AsNoTracking() (tested against SQL Server)
RavenDB same code path; compiled but not run, no RavenDB available here
Lightweight RDBMS (Postgres, SQL Server, MySQL, Oracle, SQLite, and Polecat/Fisher, which use it) page, count, order by id; Where/OrderBy refused (tested on SQLite)
CosmosDB not done: it has no ISagaStoreDiagnostics at all. Split to #5300

Ordering of ListSagaInstancesAsync is now defined: saga identity ascending, as the store compares the key (SQL Server orders a uniqueidentifier by its own byte order). It says nothing about recency; the doc comment now says so.

Polecat and Fisher register the lightweight diagnostics, so they are paging-only here rather than forwarding to their IDocumentStoreDiagnostics. Doing that would be a follow-up if filtering there matters.

🤖 Generated with Claude Code

…and counts

Adds ISagaStoreDiagnostics.QuerySagasAsync and GetQueryCapabilities
(default-implemented), reusing JasperFx DocumentQueryOptions and
ApplyCriteriaTo. Marten, EF Core and RavenDB filter, order, page and count;
the lightweight RDBMS storages (which Polecat and Fisher use) page, count and
order by id and refuse Where/OrderBy. ListSagaInstancesAsync is now ordered by
saga identity on every storage.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jeremydmiller
jeremydmiller merged commit 143edad into main Oct 30, 2026
48 checks passed
This was referenced Nov 1, 2026
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.

Query saga instances by saga type: filters, ordering and counts across saga storages

1 participant