Repository navigation
fix(routes): update the row the Edit index option finds - #113
Merged
Merged
Conversation
Upd4ting
force-pushed
the
fix/ant-1399
branch
from
November 9, 2026 14:47
0d0e4a1 to
3352a12
Compare
Edit with the index option wrote to the row whose primary key equals id. It now writes to and reads back the stored row's primary key. Fixes #90
Upd4ting
force-pushed
the
fix/ant-1399
branch
from
November 9, 2026 15:07
3352a12 to
0bbcc52
Compare
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.
Why
A route registered as
DefaultRoutes.WithOptions(DefaultRoutes.Edit, { index: "slug" })should edit the row the index finds. It found that row, then wrote the update to the row whose primary key equalsid. Usually no such row exists, so the edit was silently lost and the route still answered 200 with the old row. Fixes #90.What changes
editRowinsrc/index.tstakes the primary key (_id) of the row it found, asserts it is a string, and uses it for the update and for the read-back. Reading back by primary key also gives the right answer when the edit changes the indexed field itself. The old read through the index returned the unchanged row in that case.indexthe behaviour is the same as before, because the found row's_idis the requestedid.docs/3.routes.mddescribes the fixed behaviour in the Edit options table.issue-90-edit-indexis renamed from "fails on purpose" to a guard, andfeatures/README.mdno longer lists it as failing.flowchart LR R["PUT /edit?id=hello (index: slug)"] --> G["Query.Get(table, id, index)"] G -->|stored row, _id a1| W["WriteProperties + Lock"] W --> U_old["before: table.get('hello').update"] W --> U_new["after: table.get(stored._id).update"] U_new --> Rd["readRow by stored._id"]Proof
src/tests/index/edit_index.test.tsdrives the route against the in-memory MongoDB. One row's_idequals the indexed value, so an implementation that writes to the primary-key row fails the test.Before, with
main'ssrc/index.ts:After:
pnpm run checksprintsChecks: 8 passed, 0 failed.antelopejs-verifyat0d0e4a1, before the rebases, every featureplanlists:route-options/issue-90-edit-indexpasses. The only failures wereissue-92-getter-modeandissue-93-multi-foreign, which #117 and #116 have since fixed onmain. With #90 fixed too,features/README.mdno longer lists any journey that fails on purpose.After the rebase onto
f4872d3,pnpm run checksprintsChecks: 9 passed, 0 failed.and both new tests pass.