Skip to content

fix(query): make three silent sort gaps explicit (#157)#193

Merged
jensens merged 2 commits into
mainfrom
fix/sort-low-prio-gaps-157
Jun 29, 2026
Merged

fix(query): make three silent sort gaps explicit (#157)#193
jensens merged 2 commits into
mainfrom
fix/sort-low-prio-gaps-157

Conversation

@jensens

@jensens jensens commented Jun 29, 2026

Copy link
Copy Markdown
Member

Resolves the sort-audit gaps collected in #157. Each was a silent drop or no-op; now they either do something sensible or warn.

Changes in _process_sort

  1. sort_on=effectiveRange (DateRangeIndex, idx_key=None) was silently dropped → now sorts by pgcatalog_to_timestamptz(idx->>'effective') (the range's start date), honoring the requested direction. This is what Plone code passing effectiveRange as a default sort expects.

  2. sort_on=SearchableText was silently dropped → now sorts by full-text relevance, reusing the ts_rank_cd expression the auto-relevance path already computes, when a SearchableText term is queried. Without a term there is nothing to rank, so it logs a warning and skips instead of dropping silently.

  3. Dedicated TEXT[] columns (allowedRolesAndUsers, object_provides) produced ORDER BY idx->'key', which is NULL for every row because the value is popped out of idx JSONB into a dedicated column. Now detected (_is_dedicated_text_array_column) and ignored with a warning instead of emitting a no-op ordering.

Tests

tests/test_query.py (TestSort): effectiveRange → effective expr (+ direction); SearchableText → rank when queried, ignored (None) without a term; dedicated TEXT[] columns → ignored. The old test_sort_composite_index_ignored (which codified the silent effectiveRange drop) is replaced. Full suite: 1541 passed, 40 skipped.

Closes #157

🤖 Generated with Claude Code

jensens and others added 2 commits June 29, 2026 23:46
_process_sort silently dropped or no-op'd three sort keys:

- sort_on=effectiveRange (DateRangeIndex, idx_key=None) was dropped; now
  sorts by the effective date (the range start), which is what callers
  passing effectiveRange as a default sort expect.
- sort_on=SearchableText was dropped; now sorts by full-text relevance,
  reusing the auto-relevance rank, when a SearchableText term is queried
  (logs a warning instead of dropping silently when there is no term).
- sorting on a dedicated TEXT[] column (allowedRolesAndUsers,
  object_provides) produced ORDER BY idx->'key', which is NULL for every
  row (the value is popped to a dedicated column); now ignored with a
  warning instead of a no-op ordering.

Closes #157

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jensens
jensens merged commit 9f2464b into main Jun 29, 2026
5 checks passed
@jensens
jensens deleted the fix/sort-low-prio-gaps-157 branch June 29, 2026 21:55
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.

Sort: collection of low-prio gaps (ExtraIdxColumn TEXT[], effectiveRange, SearchableText)

1 participant