Repository navigation
server: an index with a timestamp in it is looked up by every field - #4
Merged
Merged
Conversation
In the lookup by a unique index, every field appended its predicate and the case ended in `And(ps...)` -- except a timestamp, which returned its own predicate where it stood. For an index of one timestamp that was the right answer by accident. For (desk, starts_at) it dropped the desk, so a reference matched every row at that time and Get answered whichever the database returned first. It is appended like the rest now. internal/apptest has a Shift, unique over (desk, starts_at), and a test that two shifts at one time are told apart by their desks; it fails on the old code. Generating it needed protoc-gen-orm-go f9ac5b6, whose constructors took a timestamp by value and did not compile (protobuf-orm/protoc-gen-orm-go#1), so the tool is bumped with it. Fixes #2 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 #2.
The bug
In the generated
pick<Entity>for a unique index, every field appended its predicate and the case ended inAnd(ps...). A timestamp was the exception: it returned its own predicate where it stood.For an index made of one timestamp that was right by accident. For
(desk, starts_at)it dropped the desk, so a reference matched every row at that time, andGetanswered whichever row the database returned first. With the timestamp in the middle of an index, the fields after it were never read either.The fix
The timestamp is appended like the others:
Tests
internal/apptestgainsShift, unique over(desk, starts_at).TestRefByAnIndexWithATimestampadds two shifts at one time at desksaandb, and checks that each is found by its own desk. A third desk, or the same desk at another minute, isNotFound. It fails on the old code.buf generate(twice),go generate, build, and tests in the root,runtimeandinternal/apptestpass, withinternal/apptestalso run on PostgreSQL 17.Also in this PR
Generating
Shiftneeded protoc-gen-orm-gof9ac5b6(protobuf-orm/protoc-gen-orm-go#2, merged). Before it, the query constructors took a timestamp by value and did not compile (protobuf-orm/protoc-gen-orm-go#1). The tool pin ingo.modis bumped for that.🤖 Generated with Claude Code
https://claude.ai/code/session_01KxtnpRW533bdErnW8QPhsk