Repository navigation
Apply order_by via SQL ORDER BY and compose content_contains with node_type/ids/title filters - #2312
Merged
Merged
Conversation
…e_type/ids/title filters query_nodes accepted NodeFilter.order_by but never turned it into a SQL ORDER BY, so LIMIT/OFFSET sliced an unordered result set and pagination across calls could reorder, repeat, or skip rows. SqliteStore::query_nodes now builds an ORDER BY clause (with an id ASC tiebreaker for determinism) before LIMIT/OFFSET for the direct-query path, and applies an equivalent in-memory sort for the id-chunked path where a single SQL ORDER BY can't span the merged chunk results. NodeService::query_nodes forwards order_by into NodeQuery instead of only logging that it would be handled in memory. Separately, the content_contains branch returned early with a bare "SELECT * FROM node WHERE LOWER(content) LIKE ?1", dropping node_type, ids, and title_contains entirely. All four conditions are now collected into one shared AND-chain (content/title/node_type, plus id-scoping) so a content search scoped to a type or collection no longer returns nodes of every type/outside the id set, and title_contains no longer gets silently dropped once content_contains is also set. The title stem-token fallback is now skipped when content_contains is present, since it has no notion of content matching. OrderBy moves from nodespace-core's models::node into nodespace-types so NodeQuery (the shared wire type) can carry it. Closes #2211 Closes #2212 Co-Authored-By: Claude Sonnet 5 <[email protected]>
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.
Problem
query_nodesacceptedNodeFilter.order_bybut never turned it into a SQLORDER BY, soLIMIT/OFFSETsliced an unordered result set and pagination across calls could reorder, repeat, or skip rows.Separately, the
content_containsbranch returned early with a bareSELECT * FROM node WHERE LOWER(content) LIKE ?1, droppingnode_type,ids, andtitle_containsentirely — a content search scoped to a type or collection returned nodes of every type/outside the id set, andtitle_containswas silently dropped oncecontent_containswas also set.Fix
SqliteStore::query_nodesnow builds anORDER BYclause (with anid ASCtiebreaker for determinism) beforeLIMIT/OFFSETfor the direct-query path, and applies an equivalent in-memory sort for the id-chunked path where a single SQLORDER BYcan't span the merged chunk results.NodeService::query_nodesforwardsorder_byintoNodeQueryinstead of only logging that it would be handled in memory.content_containsconditions (content/title/node_type, plus id-scoping) are now collected into one shared AND-chain. The title stem-token fallback is skipped whencontent_containsis present, since it has no notion of content matching.OrderBymoves fromnodespace-core'smodels::nodeintonodespace-typessoNodeQuery(the shared wire type) can carry it.Testing
bun run test:all: clean, no new failures.bun run quality:fix: clean (ESLint, svelte-check, tsc, rustfmt, clippy — 0 errors/warnings across the board).main(which had moved significantly since this branch was created — a v0.2.3 release was cut in the meantime); re-ran the full suite post-rebase to confirm nothing regressed.Closes #2211
Closes #2212