Repository navigation
server: an index finds an edge by the edge's name - #3
Merged
Merged
Conversation
A unique index over an edge resolves the edge through the target's Pick, and named everything else after the target too: `k.GetUser()` and `HasUserWith` for an edge called `holder`. The reference message is generated with a field named after the edge and ent names its predicate after the edge, so the two only agreed when an edge is named after what it points at -- `tenant` for a Tenant -- and any other name generated a bare server that did not compile. The Pick stays the target's, since it is the target that is being found; the getter and the predicate are now the edge's. apptest gains a Seat, unique over two edges named otherwise than their targets and over one nullable one, which is the shape a login on a person has; and a test that finds a seat by each, and that both edges of the composite index are in the predicate. Fixes #1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What was wrong
pick<Entity>resolves each edge of a unique index through the target'sPick-- right -- but named the getter and the predicate after the target as well:k.GetUser()andHasUserWithfor an edge calledholder. protoc-gen-orm-service names the field of<Entity>RefBy<Index>after the edge, and ent names its predicate after the edge, so they only agreed when an edge is named after what it points at (tenantfor aTenant). Any other name generated a bare server that did not compile -- the two cases in #1.What this changes
apps/server/app/x-pick.go: the Pick stays the target's (UserPick); the getter and the predicate are now the edge's (k.GetHolder(),seat.HasHolderWith).proto/apptest/seat.proto: aSeatunique over two edges named otherwise than their targets (holder → User,org → Tenant) and over one nullable one (deputy → User) -- the composite and the single-edge shapes from the issue -- with everything generated from it.internal/apptest/server/bare/x-indexedge_test.go: finds a seat by each index, and checks the composite one uses both edges (another holder in the same org is NotFound).Nothing generated for the existing fixtures changes: their indexed edges are named after their targets, so the old and new names are the same.
Checked
What CI runs, locally:
buf generatetwice,go generate ./...ininternal/apptest,go build, andgo test ./... -count=1at the root, inruntimeand ininternal/apptest-- the last also withAPPTEST_POSTGRESagainst PostgreSQL 17.Also seen, not changed here
A composite unique index with a timestamp among its fields returns from the pick at the timestamp instead of appending it, so the lookup drops the other fields. Filed as #2 rather than folded into this one.
🤖 Generated with Claude Code