Skip to content

Commit 719bea6

Browse files
committed
chore(golang): adopt #1094's third-review changes in the EQL build
#1094 renamed record.UInt64 to Uint64 and rewrote the generated Encrypt/Decrypt comments to state the 500-value batch size; this regenerates testusers.Contact and updates eql_test.go to match. #1094 also moved the stashgen quick start to index= columns, because that build refuses encrypt_into. This build produces TextEq, so the quick start goes back to encrypt_into=TextEq with Fields.Email.Query, and step 6 says what an eql.TextEq column binds as. Claude-Session: https://claude.ai/code/session_01V3WFXwax4J3uecpFEJ6yHc
1 parent afb61b4 commit 719bea6

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎languages/golang/cmd/stashgen/README.md‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Your program calls those functions, and it never builds or names a plan.
2121
type User struct {
2222
_ struct{} `stash:"context=users"`
2323
ID int64 `stash:"id,passthrough"`
24-
Email string `stash:"email,encrypt,index=equality;match"`
25-
Name string `stash:"name,encrypt"`
24+
Email string `stash:"email,encrypt_into=TextEq"`
25+
Name string `stash:"name,encrypt_into=TextEq"`
2626
}
2727
```
2828

@@ -40,12 +40,11 @@ Your program calls those functions, and it never builds or names a plan.
4040
```go
4141
encrypted, err := users.Encrypt(ctx, cipher, people)
4242
opened, err := users.Decrypt(ctx, cipher, encrypted)
43-
term, err := users.Fields.Email.Equality(ctx, cipher, "bob@example.com")
43+
query, err := users.Fields.Email.Query(ctx, cipher, "bob@example.com")
4444
```
4545

4646
6. Store the encrypted type.
47-
Each sealed field is one or more byte columns: `Email.Ciphertext`, `Email.Equality`, `Email.Match`.
48-
`encrypt.Ciphertext` and each term type implement `driver.Valuer` and `sql.Scanner`, so a database library binds and scans each one as bytes; map each one to its own column.
47+
Each `encrypt_into` field is one EQL column: `eql.TextEq` implements `driver.Valuer` and `sql.Scanner`, so a database library binds and scans it as the JSON a `public.eql_v3_text_eq` column holds.
4948

5049
7. Run the generator again after each change to the struct or to a tag.
5150
A change to the fields of the struct stops the build until you do.

‎languages/golang/encrypt/eql_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ func TestTextEqIsRefusedByTheBuildWithoutEQLTypes(t *testing.T) {
322322
}
323323
}
324324
// A declared type other than TextEq's plaintext, and an extended plan.
325-
wrongKind := &record.Plan{Context: []string{"users"}, Fields: []record.Field{{Name: "email", Kind: record.UInt64, Target: "TextEq"}}}
325+
wrongKind := &record.Plan{Context: []string{"users"}, Fields: []record.Field{{Name: "email", Kind: record.Uint64, Target: "TextEq"}}}
326326
if err := eqlChecker.Check(ctx, wrongKind); !errors.Is(err, encrypt.ErrEncoding) {
327327
t.Errorf("a uint64 TextEq field: Check = %v, want ErrEncoding", err)
328328
}

‎languages/golang/encrypt/internal/testusers/contact_stash.go‎

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)