Repository navigation
fix(bindx): cancel a local has-many connect when the item is removed again - #165
Merged
Merged
Conversation
…again Picking an existing entity into a has-many and removing it before saving planned a disconnect of an edge the server never held. On a create form the mutation then failed, because a create input does not accept `disconnect`; on an edit form it sent a pointless disconnect. A disconnect of an item that is only a planned connection and is in no view's server baseline now cancels the connection, the same way removing a created item cancels its create. Server members and deletes keep planning a removal. Fixes #144 Claude-Session: https://claude.ai/code/session_01XJuCeTRNu3XJ65oj8yJjvt
`remove()` falls back to `delete` for a one-has-many with a non-nullable foreign key. Picking an existing child and removing it again then planned a delete: on a new parent the create input rejected it, on a persisted parent the save would delete a row that belongs to another parent. A locally connected item that no view's server baseline holds now cancels its connect for either removal type. Claude-Session: https://claude.ai/code/session_01XJuCeTRNu3XJ65oj8yJjvt
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 #144.
Problem
connect()on a has-many records the item inplannedAdditionsasconnected. Removing it again goes throughHasManyStore.removeFromHasMany, which cancelled only additions of kindcreated; for everything else it calledplanHasManyRemoval, so the item ended up inplannedRemovalsalthough the server never held the edge.MultiSelectField, remove it with the chip's × or a second click, save) the mutation fails:"disconnect" is not defined by type …CreateInput. This hit an NPI production form today.remove()picksdeletefor a one-has-many with a non-nullable FK. There, pick-then-remove planned a delete. On a new parent the create input rejected it; on a persisted parent the save would delete a row that belongs to another parent.Fix
Any removal of an item that is a planned
connectedaddition and is in no view's server baseline (relationServerIds) now cancels the addition. This is the same path that removing acreateditem already takes. Removing or deleting a server member still plans the removal, including an item that was removed, re-connected and removed again.Tests
tests/unit/persistence/removeUnsavedHasManyPick.test.tshas 9 cases; the pick-then-remove ones fail without the fix. The full suite passes (2558), andtsc --buildand eslint are clean. An independent review checked filtered views, the undo journal, in-flight persist reconciliation (reconcileHasManyStatere-plans the removal for a connect that was already sent) and has-one (already guarded).https://claude.ai/code/session_01XJuCeTRNu3XJ65oj8yJjvt