Breeze 1.4.8 Bug: Query MergeStrategy.OverwriteChanges never notifies entityChanged or hasChanges
-
21-12-2019 - |
Question
When I requery my only dirty entity with MergeStrategy.OverwriteChanges, the manager says hasChanges is true, even though the entityState is unchanged. This is because the entityChanged & hasChangesChanged are never published.
Looking at the source in mergeEntity (line 14258) the intended code for this will never work as it is testing the entity state after it has been updated & its testing for the existance of the isUnchanged function not it's return value.
I think it should be something like
if (mergeStrategy === MergeStrategy.OverwriteChanges
|| targetEntityState.isUnchanged()) {
var isTargetEntityStateUnchanged = targetEntityState.isUnchanged();
...
// this is needed to handle an overwrite of a modified entity with an unchanged entity
// which might in turn cause _hasChanges to change.
if (!isSaving && !isTargetEntityStateUnchanged) {
em._notifyStateChange(targetEntity, false);
}
Solution
As of Breeze 1.4.9 (or later), available now, this has been fixed. and thanks for finding it.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow