Skip to content

Fix DocumentCatalog search on interface-typed index filters - #278

Merged
MikeAlhayek merged 1 commit into
mainfrom
ma/fix-catalog-search-interface-index
Oct 19, 2026
Merged

MikeAlhayek merged 1 commit into
mainfrom
ma/fix-catalog-search-interface-index

Conversation

@MikeAlhayek

Copy link
Copy Markdown
Member

Problem

DocumentCatalog<T, TIndex>.PageAsync threw on every search. With a QueryContext that sets Name or Source, it filtered with:

query.With<INameAwareIndex>(x => x.Name.Contains(context.Name))
query.With<IDisplayTextAwareIndex>(x => x.DisplayText.Contains(context.Name))
query.With<ISourceAwareIndex>(x => x.Source == context.Source)

YesSql maps the type argument of With<TIndex> to an index table. A marker interface has no table, so SQL went to a table that does not exist:

SqliteException: SQLite Error 1: 'no such table: IDisplayTextAwareIndex_Document'.

The same happens for INameAwareIndex_Document and ISourceAwareIndex_Document. A downstream host found it: every server-side admin list search returned HTTP 500 (Orchard Core AdminList with Options.Search).

Fix

PageAsync now builds the filter and the sort expressions for the concrete TIndex. It uses the interface's PropertyInfo on a TIndex parameter, which is the same expression the compiler emits for a generic TIndex constrained to the interface (as NamedDocumentCatalog.FindByNameAsync does). So YesSql binds the column to the concrete index table that Session.Query<T, TIndex>() already joined. The behavior is otherwise unchanged: Name checks INameAwareIndex first, then IDisplayTextAwareIndex; Sorted orders by the same column; Source filters by equality.

Tests

New DocumentCatalogPageTests run PageAsync against a real in-memory SQLite YesSql store with test index types:

  • name search on an INameAwareIndex, sorted and not sorted
  • display text search on an IDisplayTextAwareIndex, sorted and not sorted
  • name and source together
  • search with paging (count is all matches, entries are the requested page)

All 6 fail on main with the no such table error and pass with the fix. The YesSql and catalog tests (158) pass, and the test project builds with -warnaserror -p:TreatWarningsAsErrors=true -p:RunAnalyzers=true.

Docs

  • changelog/2.0.0.md: a "Fixed" entry.
  • core/data-storage.md: the Pagination section now tells how QueryContext filters a page.
  • The docs site builds.

PageAsync filtered with query.With<INameAwareIndex>(...),
With<IDisplayTextAwareIndex>(...) and With<ISourceAwareIndex>(...).
YesSql maps the type argument to an index table, and a marker interface
has none, so any search or source filter threw
"no such table: IDisplayTextAwareIndex_Document".

Build the filter and the sort expressions for the concrete TIndex, and
add SQLite integration tests that page a catalog with a search term.
@MikeAlhayek
MikeAlhayek merged commit a42241b into main Oct 19, 2026
10 checks passed
@MikeAlhayek
MikeAlhayek deleted the ma/fix-catalog-search-interface-index branch October 19, 2026 20:12
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