fix(query): make three silent sort gaps explicit (#157)#193
Merged
Conversation
_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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_sortsort_on=effectiveRange(DateRangeIndex,idx_key=None) was silently dropped → now sorts bypgcatalog_to_timestamptz(idx->>'effective')(the range's start date), honoring the requested direction. This is what Plone code passingeffectiveRangeas a default sort expects.sort_on=SearchableTextwas silently dropped → now sorts by full-text relevance, reusing thets_rank_cdexpression 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.Dedicated
TEXT[]columns (allowedRolesAndUsers,object_provides) producedORDER BY idx->'key', which isNULLfor every row because the value is popped out ofidxJSONB 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; dedicatedTEXT[]columns → ignored. The oldtest_sort_composite_index_ignored(which codified the silenteffectiveRangedrop) is replaced. Full suite: 1541 passed, 40 skipped.Closes #157
🤖 Generated with Claude Code