Fix perf of rectification after updateAttributes

Improve the id-detection algorithm in the "after save" hook
to correctly handle "updateAttributes" as a single-model change
and DO NOT trigger full "rectify all" scan.
This commit is contained in:
Miroslav Bajtoš 2015-09-17 18:58:52 +02:00
parent 15c1ac8bb5
commit 89326c7630
1 changed files with 6 additions and 2 deletions

View File

@ -1419,8 +1419,12 @@ module.exports = function(registry) {
}; };
function rectifyOnSave(ctx, next) { function rectifyOnSave(ctx, next) {
if (ctx.instance) { var instance = ctx.instance || ctx.currentInstance;
ctx.Model.rectifyChange(ctx.instance.getId(), reportErrorAndNext); var id = instance ? instance.getId() :
getIdFromWhereByModelId(ctx.Model, ctx.where);
if (id) {
ctx.Model.rectifyChange(id, reportErrorAndNext);
} else { } else {
ctx.Model.rectifyAllChanges(reportErrorAndNext); ctx.Model.rectifyAllChanges(reportErrorAndNext);
} }