Skip to content

feat(pushdown): generalise orderBy rendering beyond OData (#120); $select superset guard verified (#116) - #139

Merged
jeffreyaven merged 1 commit into
mainfrom
feat/odata-pushdown-116-120
Sep 4, 2026
Merged

feat(pushdown): generalise orderBy rendering beyond OData (#120); $select superset guard verified (#116)#139
jeffreyaven merged 1 commit into
mainfrom
feat/odata-pushdown-116-120

Conversation

@jeffreyaven

Copy link
Copy Markdown
Member

Closes #120. Closes #116.

#120 - generalise orderBy pushdown beyond OData

applyPushdownOrderBy hard-required syntax: odata and always rendered
<column> <asc|desc>, so an API that expresses ordering any other way (OpenAI's
direction-only ?order=desc, GitHub's ?direction=asc, sort=-name prefix
styles) could not use the pushdown at all - unlike top/skip/count, which
honour any paramName.

orderBy already carries syntax as its render directive, and the docs listed
prefix and suffix values the code never rendered. The issue sketched a new
algorithm key; to avoid two overlapping knobs the new renderings are
additional syntax values:

syntax renders example
odata (default) col asc|desc, comma-joined $orderby=created_at desc
prefix -col for desc, col for asc sort=-created_at,name
suffix col:asc|desc sort=created_at:desc
column_only column names only sort=created_at
direction_only asc/desc alone; exactly one term on an explicit supportedColumns allowlist order=desc

Anything the syntax cannot express (unsupported column, more than one term for
direction_only, unknown syntax) emits nothing and ORDER BY stays client-side,
which remains authoritative. The odata path is byte-identical. No registry
provider currently declares an orderBy pushdown, so rendering prefix/suffix
changes no existing wire behaviour.

#116 - $select superset guard

Delivered in #124 (83c0a2e, released in v0.5.4-alpha01): applyPushdownSelect
extends the emitted $select with every column pushed into $filter or
$orderby, subject to the select allowlist, and ApplyPushdown runs filter and
order-by before select for that reason. The four superset tests from #124 cover
the issue's acceptance criteria (superset, unsupported column skipped, no change
when already projected, SELECT * still emits no $select) and pass here. No
further code is required; listed so the issue closes with the PR.

Verification

  • go build ./..., gofmt, go test ./... clean; lint clean on changed files.
  • New tests: direction_only asc/desc, refused for an unsupported column,
    multiple terms, or a missing allowlist; prefix/suffix/column_only
    rendering; unknown syntax emits nothing; OData default unchanged.
  • End-to-end (stackql built against this branch vs v0.5.4-alpha01, local file
    registry, mock API logging raw queries), resource with
    orderBy: {paramName: order, syntax: direction_only, supportedColumns: [created_at]}:
    • ORDER BY created_at DESC -> /v1/containers?order=desc (baseline: no param)
    • ORDER BY created_at ASC -> /v1/containers?order=asc
    • ORDER BY id DESC -> no param, rows still ordered client-side

🤖 Generated with Claude Code

…lect superset guard verified (#116)

orderBy `syntax` now renders `prefix`, `suffix`, `column_only` and
`direction_only` in addition to `odata` (default, byte-identical).
`direction_only` requires exactly one term on an explicit supportedColumns
allowlist and emits asc|desc alone (OpenAI-style `?order=desc`). Anything a
syntax cannot express emits nothing; client-side ORDER BY stays authoritative.

The #116 superset guard shipped in #124 and its tests pass here; no further
code is needed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jeffreyaven
jeffreyaven merged commit 0bb4c24 into main Sep 4, 2026
10 checks passed
@jeffreyaven
jeffreyaven deleted the feat/odata-pushdown-116-120 branch September 4, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants