Fix composite primary auto-fill for preInsert hook fields and add regression test#8550
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/pubkey/rxdb/sessions/08237573-b364-44bc-847f-90e402f47a85 Co-authored-by: pubkey <8926560+pubkey@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
pubkey
May 19, 2026 10:31
View session
Owner
|
rel #8527 |
Owner
|
@copilot propose a fix |
Agent-Logs-Url: https://github.com/pubkey/rxdb/sessions/8d80a707-d21c-45b6-95ed-f0d03a6e3bfb Co-authored-by: pubkey <8926560+pubkey@users.noreply.github.com>
Contributor
Author
Copilot
AI
changed the title
Add regression test for composite primary auto-fill from preInsert hook fields
Fix composite primary auto-fill for preInsert hook fields and add regression test
May 19, 2026
Contributor
✅ Verify Test Reproduction: Tests FAILED without the fix (expected)This confirms the changed tests correctly reproduce the bug that the source changes fix. This workflow runs the changed tests without the source fix to verify they reproduce the bug. Show output |
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.
This PR fixes a composite primary key insertion path where
idshould be derived automatically when apreInserthook sets onlynameandnumber.Problem scope
idcomposed fromnameandnumber.{}with apreInserthook that populates those fields should succeed and materializeidfrom the composite key.DOC18before hook-derived fields could be used for composite primary key generation.Changes in this PR
Added a focused regression test in
test/unit/hooks.test.tsunderdescribeParallel('issues'):preInserthook that sets:docData.name = 'alice'docData.number = 5id === 'alice|5'.Implemented fix in insert flow:
src/rx-collection.ts, whenpreInserthooks exist, document preparation now skips composite primary fill before hooks.idgeneration.Updated helper API in
src/rx-collection-helper.ts:fillObjectDataBeforeInsert()now accepts an optionalskipPrimaryKeyFillflag (defaultfalse) to support the hook-first flow.Changelog
orga/changelog/add-test-composite-primary-preinsert-hook.mdorga/changelog/fix-composite-primary-preinsert-hook.md