Skip to content

Add server row sorting, filtering, and search#178

Merged
priethor merged 4 commits into
mainfrom
priethor/add/rows-sort-filter-search
May 13, 2026
Merged

Add server row sorting, filtering, and search#178
priethor merged 4 commits into
mainfrom
priethor/add/rows-sort-filter-search

Conversation

@priethor

@priethor priethor commented May 13, 2026

Copy link
Copy Markdown
Collaborator

What

Closes #102.

Moves common collection row queries onto GET /cortext/v1/rows: sorting, field filters, grouped filters, and split-term search. The server now handles the field types we can query reliably, while unsupported query shapes stay on the client instead of being silently sent to the endpoint.

Why

The table already fetched rows from the rows endpoint, but search and richer filters still depended on client-side behavior. This adds server query support for the normal database-table cases without taking on server pagination changes in this PR.

How

Server-supported fields:

Field Sort Filter Search
Title Yes Yes Yes
Text Yes Yes Yes
Email Yes Yes Yes
URL Yes Yes Yes
Number Yes Yes No
Date Yes Yes No
Datetime Yes Yes No
Select Yes, by stored value Yes No
Multiselect No Yes No
Checkbox Yes Yes No
Created / Last edited Yes No No
Created by / Last edited by No No No
Relation No No No
Rollup No No No
  • Uses a local field capability map until WordPress or DataViews exposes a capability contract for custom field types.
  • Compiles supported filters through RowsFilterQuery and a small WP_Meta_Query extension for comparison shapes WP core does not support yet.
  • Sends only server-safe DataViews query state, with client fallback when a view contains unsupported query parts.
  • Leaves select sorting as stored-value sorting for now, not curated option order.

Testing Instructions

  1. Create a collection with title, text, number, date, datetime, select, multiselect, checkbox, email, URL, relation, and rollup fields.
  2. Sort by title, text, number, date, datetime, select, checkbox, and URL. Check that supported fields sort correctly.
  3. Add filters for title/text/email/URL contains, number greater than, date before, select is one of, multiselect contains, and checkbox checked. Check that visible rows match.
  4. Search for two words where one is in the title and the other is in a text-like field. Check that the row stays visible.
  5. Try sorting or filtering relation and rollup fields. They should not be treated as server-supported fields.

Screen recording

Grabacion.de.pantalla.2026-05-13.a.las.16.57.16.mov

@priethor priethor force-pushed the priethor/add/rows-sort-filter-search branch 2 times, most recently from 371c6c3 to c09db2e Compare May 13, 2026 14:56
@priethor priethor force-pushed the priethor/add/rows-sort-filter-search branch from c09db2e to 0933ac6 Compare May 13, 2026 15:04
The controller was juggling a token, three side-channel query vars
(cortext_rows_where, cortext_rows_sort, cortext_rows_join) and two
inline closures to install scoped posts_where/posts_clauses filters
around its WP_Query call. RowsQueryScope owns all of that now: the
controller hands it the SQL fragments and the sort, and gets a
WP_Query back. Token still exists, hidden inside the scope; the
other query vars are gone because the closures capture the data
directly.

build_query_args goes back to a clean signature with no SQL params.
@priethor priethor merged commit 721d4a2 into main May 13, 2026
6 checks passed
@priethor priethor deleted the priethor/add/rows-sort-filter-search branch May 13, 2026 21:00
@priethor priethor added this to the 0.1.0 milestone May 28, 2026
@priethor priethor added type: enhancement Improvement to existing behavior. area: collections Fields, rows, views, DataViews, relations, rollups, formulas, and row properties. labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: collections Fields, rows, views, DataViews, relations, rollups, formulas, and row properties. type: enhancement Improvement to existing behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server-side sorting, filtering, and full-text search across collection fields

1 participant