Repository navigation
query: a message-typed field of a reference is taken as its pointer, and compared by value - #2
Merged
Merged
Conversation
…and compared by value A unique index with a timestamp among its fields generated a constructor that took the timestamp by value -- `ShiftBySlot(desk string, starts_at timestamppb.Timestamp)` -- and so did not compile: `useGoType` with the decayed type names a message without its pointer, and only an edge was given one. The constructors now take what the reference's setter takes, written once in argType, for a unique field as well as an index. And `Picks` compared the two timestamps with `==`, which compiles and asks whether they are one message: a reference built anywhere but from the row's own field never picked the row. A message-typed field is compared with proto.Equal. internal/apptest has a Shift, unique over (desk, starts_at), and a test of both; the old generator does not build it. Fixes #1 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KxtnpRW533bdErnW8QPhsk
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.
Fixes #1.
A unique index with a timestamp among its fields generated two defects in
query.g.go:ShiftBySlot(desk string, starts_at timestamppb.Timestamp)took the timestamp by value.useGoTypewith the decayed type names a message without its pointer, and only an edge was given one (*…Ref). A newargTypegives the type the reference's setter takes. It is used by all four constructors (By<Field>,GetBy<Field>,By<Index>,GetBy<Index>), so a unique message-typed field is covered as well.Pickscompared pointers.(x.GetStartsAt() == v.GetStartsAt())compiles, and asks whether the two are one message. A reference built anywhere other than from the row's own field never picked the row. A message-typed field is now compared withproto.Equal, in the single-field case and in the index case.Tests
internal/apptestgainsShift, unique over(desk, starts_at), andTestRefByAnIndexWithATimestamp. A reference picks its row from a freshTimestampof the same instant, does not pick another desk or another time, and a row with no identifier is named by its index.On the old generator the package does not build (
cannot use v2 (variable of type *timestamppb.Timestamp) as timestamppb.Timestamp value in argument to ShiftBySlot). Locallybuf generate(twice), gofmt, build, vet andgo test ./...pass.Found while fixing protobuf-orm/protoc-gen-orm-ent#2, whose test needs this to compile.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KxtnpRW533bdErnW8QPhsk