You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
docs(golang): give the sort expression for each ordered EQL type - #1915
The Go SDK docs now say how to sort each ordered EQL column correctly. EQL (Encrypt Query Language) is the PostgreSQL extension that stores and queries the encrypted values. The type table said that ordered types support ORDER BY. But a plain ORDER BY col returns rows in the wrong order, with no error.
The docs also now say that decimal, date, and timestamp fields can take an order index. They no longer say that bytes can.
Changes
languages/golang/encrypt/README.md:
The EQL type table gives the sort expression for each ordered type. The OrdOre types now have rows of their own, because they sort with a different function.
A "Take care" note before the table warns that a plain ORDER BY col sorts wrongly, with no error. The note also says that eql_v4.ord_term(col) fails on an OrdOre or TextSearchOre column.
The "What is stored" table lists ore and ope for encrypt.Decimal, encrypt.Date, and time.Time, with their query methods. The sentence that said these orders are refused is replaced.
The Queries table lists every type that takes index=ore or index=ope.
languages/golang/encrypt/doc.go:
The list of ordered EQL types includes DateOrd, TimestampOrd, and NumericOrd. It also gives the sort expressions and the warning.
Bytes are removed from the types that take ORE (order-revealing encryption) and OPE (order-preserving encryption). A new sentence says that stashgen refuses an order index on bytes.
languages/golang/CHANGELOG.md: an entry under Unreleased.
The sort expression for each type:
Types
Sort with
*Ord, *OrdOpe, TextSearch
ORDER BY eql_v4.ord_term(col)
*OrdOre, TextSearchOre
ORDER BY eql_v4.ord_term_ore(col)
Verification
Sort expressions. I read them from the EQL v4 SQL source in packages/eql/src/v3/scalars/*/. EQL v4 is built from that source. eql_v4.ord_term is defined for every *_ord and *_ord_ope domain, and for text_search. eql_v4.ord_term_ore is defined for every *_ord_ore domain, and for text_search_ore. No ord_term is defined for an OrdOre domain. So PostgreSQL finds more than one candidate, and the call fails (EQL v4: ORDER BY eql_v4.ord_term(col) on an OrdOre column fails with "function is not unique" #1903).
Why a plain ORDER BY is wrong. Every EQL type is CREATE DOMAIN ... AS jsonb (for example bigint_types.sql). So PostgreSQL sorts by jsonb order. The EQL test suites sort with the same expressions: tests/encryption/tests/v4_order.rs with ord_term, and v4_ore_block.rs with ord_term_ore. I did not run SQL against a database for this PR. The issue reports the wrong order as tested in a database.
Order indexes. I ran a throwaway test, not committed, that calls stashgen with the real embedded engine:
index=ore and index=ope on encrypt.Decimal, encrypt.Date, and time.Time are accepted. stashgen writes Lt, Lte, Gt, Gte, and Between for each.
index=ore and index=ope on []byte are refused: "the declared type has no such index".
encrypt_into=DateOrd, DateOrdOre, TimestampOrdOpe, and NumericOrdOre are accepted, with Lt, Lte, Gt, and Gte.
CGO_ENABLED=0 go test -timeout=25m ./encrypt/ ./stashgen/ ./cmd/stashgen/ passed, after I built the guests with mise.
go vet ./encrypt/ reported nothing. gofmt -l listed no files. golangci-lint run ./encrypt/ ./stashgen/ (2.14.0) reported 0 issues.
I ran the plain-language checker on the new text and fixed what it found. The README text follows the file's existing style, with no serial comma.
Clarified which sort expressions to use when ordering encrypted values, and noted that plain ORDER BY sorts stored JSON rather than the underlying values.
Expanded guidance for equality, ordering, and range queries on decimal and date values, including time.Time.
Clarified that byte fields do not support order indexes.
Each EQL type is a PostgreSQL domain over jsonb. So a plain ORDER BY col
sorts the stored JSON, and returns rows in the wrong order with no error.
The type table said ordered types support ORDER BY. It now gives the
expression that sorts correctly for each type:
- eql_v4.ord_term(col) for the Ord, OrdOpe, and TextSearch types.
- eql_v4.ord_term_ore(col) for the OrdOre and TextSearchOre types. On
these, ord_term fails with "function is not unique".
The package documentation says the same.
The README said that a decimal, date, or timestamp field takes an equality
index only. stashgen accepts an ore or ope index on all three. It writes
the Lt, Lte, Gt, Gte, and Between methods for them. The type and query
tables now say so.
The package documentation said ORE and OPE apply to bytes. stashgen
refuses an order index on bytes, so that claim is removed.
Refs #1851
Refs #1855
Refs #1857
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CtEQzxj55RUn35dkbhdwQk
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Auto reviews are disabled on base/target branches other than the default branch.
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The Go encryption documentation now describes order indexes for decimal, date, and timestamp fields, specifies SQL sorting expressions for ordered columns, and states that stashgen refuses order indexes on byte fields.
Changes: Go encryption documentation
Layer / File(s)
Summary
Document order-index support languages/golang/encrypt/README.md, languages/golang/CHANGELOG.md
The README and changelog list ore and ope indexes and ordering queries for encrypt.Decimal, encrypt.Date, and time.Time. The README describes the comparison precision for these types.
cipherstash/stack#1337 — Adds the date, timestamp, and decimal order-term support that this PR documents.
Suggested reviewers:coderdan
Merge Risk: Minimal · previous review ebda3
This documentation-only change corrects the sort expressions for ordered types, the index support for decimal, date and timestamp fields, and the bytes restriction. It has no runtime effect and is safe to merge. The author has not run SQL against a database for this PR, so the sort-expression guidance rests on the linked issue's report.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "docs(golang): give the sort expression for each ordered EQL type" matches the main change. The PR updates the Go SDK README and package docs to give the correct sort expression (ord_term or…
Linked Issues check
The linked issues are docs-only, but the changed package comments are Go source, so they count as coding requirements here. Evidence is the head revision of languages/golang/encrypt/doc.go. (1) [#1851…
Out of Scope Changes check
All changed files are documentation for the Go SDK: languages/golang/encrypt/README.md, languages/golang/encrypt/doc.go, and languages/golang/CHANGELOG.md. Each change maps to one of #1851, #1855 or #…
Full details: Title check
Explanation
The title "docs(golang): give the sort expression for each ordered EQL type" matches the main change. The PR updates the Go SDK README and package docs to give the correct sort expression (ord_term or ord_term_ore) for each ordered EQL type, and it adds a warning that plain ORDER BY sorts the stored JSON. The title is specific and concise, and it follows a conventional commit style.
Full details: Linked Issues check
Explanation
The linked issues are docs-only, but the changed package comments are Go source, so they count as coding requirements here. Evidence is the head revision of languages/golang/encrypt/doc.go. (1) [#1851] The doc comment gives the sort expression per type: Ord, OrdOpe and TextSearch use ORDER BY eql_v4.ord_term(col), and OrdOre and TextSearchOre use ORDER BY eql_v4.ord_term_ore(col). It warns that a plain ORDER BY col returns rows in the wrong order with no error. (2) [#1855] The ORE/OPE list in the Declarations section now covers decimals, dates and timestamps. The ordered-type list includes DateOrd, TimestampOrd and NumericOrd. (3) [#1857] The Declarations section says ORE and OPE apply to integers of 16 bits or more, floats, text, decimals, dates and timestamps. It states that stashgen refuses an order index on bytes. Bytes no longer appear in that list. The README table changes for #1851 and #1855 and the CHANGELOG entry were not readable with the tools available. Their content is taken from the PR description and the raw summary, not from direct inspection. The PR does not need to fix the database-level ord_term error (#1903); the PR documents it only.
Full details: Out of Scope Changes check
Explanation
All changed files are documentation for the Go SDK: languages/golang/encrypt/README.md, languages/golang/encrypt/doc.go, and languages/golang/CHANGELOG.md. Each change maps to one of #1851, #1855 or #1857. The doc.go hunks shown in the evidence (sort expressions, order-index type list, bytes removal) belong to those issues. The PR adds no code behavior changes, so no unrelated functional change is present. The README and CHANGELOG hunks were not directly read, so this verdict relies on the PR description and summary for those files.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Reviewing files that changed from the base of the PR and between 1885e92 and ebda37e.
Files selected for processing: 3
languages/golang/CHANGELOG.md
languages/golang/encrypt/README.md
languages/golang/encrypt/doc.go
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
Checked and not posted: the raw Ope "ORDER BY" line (README.md:430) is correct for a raw bytea term column. Open questions for the author: state the ord_term/ord_term_ore rule once rather than in 20 rows, so a fix to #1903 is one edit; stashgen/enginetest lists fewer EQL types than the real engine (test-only). Issues #1851, #1855 and #1857 are met. No changeset is needed: the Go module releases outside Changesets.
Review found four gaps in the type docs.
- The README said an order index follows the equality rules. Those rules
say an integer equals itself at every width. But each integer width has
its own order term, so the sentence now covers decimals, dates, and
timestamps only.
- The ordered Date, Timestamp, and Numeric rows left out = and <>. EQL v4
defines both on those domains.
- The package docs left out the OrdOre types, TextSearch, and
TextSearchOre, from both the Go field types and the operators. The Go
field types are now a list by family.
- The paragraphs are wrapped again at the file's width.
Refs #1851
Refs #1855
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CtEQzxj55RUn35dkbhdwQk
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
documentationImprovements or additions to documentationGolangPull requests that update Go codeSDK
2 participants
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.
Summary
The Go SDK docs now say how to sort each ordered EQL column correctly. EQL (Encrypt Query Language) is the PostgreSQL extension that stores and queries the encrypted values. The type table said that ordered types support
ORDER BY. But a plainORDER BY colreturns rows in the wrong order, with no error.The docs also now say that decimal, date, and timestamp fields can take an order index. They no longer say that bytes can.
Changes
languages/golang/encrypt/README.md:OrdOretypes now have rows of their own, because they sort with a different function.ORDER BY colsorts wrongly, with no error. The note also says thateql_v4.ord_term(col)fails on anOrdOreorTextSearchOrecolumn.oreandopeforencrypt.Decimal,encrypt.Date, andtime.Time, with their query methods. The sentence that said these orders are refused is replaced.index=oreorindex=ope.languages/golang/encrypt/doc.go:DateOrd,TimestampOrd, andNumericOrd. It also gives the sort expressions and the warning.languages/golang/CHANGELOG.md: an entry under Unreleased.The sort expression for each type:
*Ord,*OrdOpe,TextSearchORDER BY eql_v4.ord_term(col)*OrdOre,TextSearchOreORDER BY eql_v4.ord_term_ore(col)Verification
packages/eql/src/v3/scalars/*/. EQL v4 is built from that source.eql_v4.ord_termis defined for every*_ordand*_ord_opedomain, and fortext_search.eql_v4.ord_term_oreis defined for every*_ord_oredomain, and fortext_search_ore. Noord_termis defined for anOrdOredomain. So PostgreSQL finds more than one candidate, and the call fails (EQL v4:ORDER BY eql_v4.ord_term(col)on anOrdOrecolumn fails with "function is not unique" #1903).ORDER BYis wrong. Every EQL type isCREATE DOMAIN ... AS jsonb(for examplebigint_types.sql). So PostgreSQL sorts byjsonborder. The EQL test suites sort with the same expressions:tests/encryption/tests/v4_order.rswithord_term, andv4_ore_block.rswithord_term_ore. I did not run SQL against a database for this PR. The issue reports the wrong order as tested in a database.index=oreandindex=opeonencrypt.Decimal,encrypt.Date, andtime.Timeare accepted. stashgen writesLt,Lte,Gt,Gte, andBetweenfor each.index=oreandindex=opeon[]byteare refused: "the declared type has no such index".encrypt_into=DateOrd,DateOrdOre,TimestampOrdOpe, andNumericOrdOreare accepted, withLt,Lte,Gt, andGte.CGO_ENABLED=0 go test -timeout=25m ./encrypt/ ./stashgen/ ./cmd/stashgen/passed, after I built the guests with mise.go vet ./encrypt/reported nothing.gofmt -llisted no files.golangci-lint run ./encrypt/ ./stashgen/(2.14.0) reported 0 issues.Related
Closes #1851
Closes #1855
Closes #1857
Refs #1903, the
ord_termerror onOrdOrecolumns. This PR documents the workaround and does not fix the error.Review notes
cmd/stashgen/README.mdunchanged. Its type table makes noORDER BYclaim. It already lists the order types for decimals, dates, and timestamps.=or<>, as before. Those operators are outside these issues, so I did not check them.🤖 Generated with Claude Code
https://claude.ai/code/session_01CtEQzxj55RUn35dkbhdwQk
Summary by CodeRabbit
ORDER BYsorts stored JSON rather than the underlying values.time.Time.