Skip to content

fix: omit empty rank conditions for sort-only scopes - #600

Merged
nertzy merged 2 commits into
Casecommons:masterfrom
sean0407:codex/fix-sort-only-empty-conditions
Oct 17, 2026
Merged

nertzy merged 2 commits into
Casecommons:masterfrom
sean0407:codex/fix-sort-only-empty-conditions

Conversation

@sean0407

Copy link
Copy Markdown
Contributor

Summary

ScopeOptions#conditions
  discard sort_only features
+ if no filter expressions remain: return nil
  otherwise: build the OR predicate

Fixes #598. When every search feature is sort_only, the empty predicate currently reaches .where and generates invalid SQL with a bare WHERE.

Evidence

  • Before: The focused regression example failed with PG::SyntaxError at WHERE ).
  • After: The focused example passed (1 example, 0 failures); spec/integration/pg_search_spec.rb passed (100 examples, 0 failures).
  • bundle exec standardrb lib/pg_search/scope_options.rb spec/integration/pg_search_spec.rb passed.
  • Patch policy passed: 2 files, 16 changed lines, no binary changes.

Merge Danger

Door: Two-way

Blast Radius: Narrow

Only scopes with no non-sort_only conditions now omit the empty predicate. Scopes with filter expressions continue to build the same OR condition.

@nertzy
nertzy merged commit a3c244e into Casecommons:master Oct 17, 2026
13 checks passed
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_only: true still creates corrupt subquery with bare WHERE (regression from #560, still in 2.4.0)

2 participants