fix(pinia-orm): scope decorator mutators, casts & hidden fields per entity#2027
Merged
Conversation
…ntity Mutators, casts and hidden fields registered via setMutator/setCast/ setHidden (and thus via the Mutate, Cast and Hidden decorators) were stored on shared static objects of the base Model class, keyed only by field name. A mutation registered for one entity was therefore applied to every entity that has a field with the same name. They are now keyed by entity, like the schema registries already are. fixes #1937 fixes #1992
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2027 +/- ##
==========================================
+ Coverage 99.43% 99.50% +0.06%
==========================================
Files 82 82
Lines 3019 3022 +3
Branches 529 530 +1
==========================================
+ Hits 3002 3007 +5
+ Misses 14 12 -2
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Jul 19, 2026
Merged
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.
Bug
fieldMutators,fieldCastsand thehiddenarray live as shared static objects on the baseModelclass.setMutator(),setCast()andsetHidden()(used by the@Mutate,@Castand@Hiddendecorators) wrote into these shared objects keyed only by field name — so a mutator/cast/hidden registered for one entity leaked to every other entity with a same-named field.firstNameon two entities — only one runs, for both entitiessetMutator()on one store mutates all same-named fields in every storeFix
Key
fieldMutatorsandfieldCastsbymodelEntity()— the same patternschemas,registriesandfieldsOnDeletealready use.setHidden()now does copy-on-write so it no longer pushes into the base class' shared array.Tests
4 new regression tests (mutator decorator, setMutator, cast decorator, hidden decorator across two entities with same-named fields). All fail before the fix, pass after; full suite green (401 tests).
fixes #1937
fixes #1992