Repository navigation
Conversation
Cipher.query(field, value) returns the equality query term as a str. The SQL casts it to the marker's query_sql_domain, such as eql_v4.query_text_eq, and EQL's = compares it with the stored eq_term. The term comes from the index key in the loaded keyset, so a query makes no request once the client is built. The field is named by a string. ADR-0002 records why: a class attribute such as User.email does not exist on a plain dataclass, and core does not change the user's class. The later SQLAlchemy layer may accept the attribute. Cipher.query raises QueryError before the extension is called: query_unknown_field for a name that is not a declared field, and query_unsupported for a Text or Passthrough field. The value is checked as encrypt checks it. The two now share one function. The live tests search one row out of two, check that EXPLAIN uses the eq_term index, and check that 100 queries make no request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cipher.query accepted every marker with a query type. The engine answers equality only through the eq index. So a field such as IntegerOrd or TextMatch passed the check, built the client, loaded the keyset, and then failed as a plain StashError. Cipher.query now checks for the eq index, and raises QueryError (query_unsupported) before any request. The error message lists only the fields with an equality query. core::query checks the same from the plan, with no I/O, before it builds the client. The extension maps query_* codes to QueryError. Quote the ADR-0002 ticket value, so YAML does not read it as a comment. Add a comment on the copy of the term's bytes: QueryTerm has no accessor that gives up its operand. Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true |
|
Contributor
|
Found 2 test failures on Blacksmith runners: Failures
|
This branch has not been deployed
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.
![Fix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light-3x.png)
Summary
Cipher.querynow makes an equality query term, so a program can search an encrypted column. EQL (Encrypt Query Language) is CipherStash's set of PostgreSQL types for encrypted values. The term is astr. The SQL casts it to the field's query type, and EQL's=compares it with the stored values. After the first operation of the process, a query sends no request to CipherStash.Changes
Cipher.query(field, value)returns the term. The newQueryErroris aStashError.query_unknown_field. A field whose marker has noeqindex isquery_unsupported. Examples areText,Passthrough,IntegerOrd, andTextMatch. The message lists the fields with an equality query.encrypt. Both calls now use one function,field_value.crates/core/src/query.rscalls the engine'squery_termwith theeqoperator, as Go'sCipher.QueryTermdoes. It checks the field's operators from the plan before it builds the client.User.emaildoes not exist on a plain dataclass. Core does not change the user's class. The later SQLAlchemy layer may accept the attribute.query, and the design line lists ADR-0002.Verification
gate-probetests.mise run test:cargo: 30 core tests and 5 extension tests passed.cargo fmt --check, and mypy: no findings. pyright: 0 errors and the 3 earlier warnings.pnpm run test:scripts: 83 of 83 files pass.hmkey, the equality term, and itsi. The term has no ciphertextc.livejob on this PR.Related
Closes #1391. Refs #1341.
Review notes
EXPLAINusing theeq_termindex, and 100 queries with no request.USING hash, as EQL's own docs do. The EQL test that I copied theEXPLAINapproach from uses a btree index. So thelivejob is the first check of the hash index withEXPLAIN.QueryTerminstack-encrypthas no accessor that gives up its operand. A comment in the code says this.pub(crate), so the query tests can reuse them.🤖 Generated with Claude Code