diff --git a/lib/dao.js b/lib/dao.js index 827cdd3e..70355dee 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -521,6 +521,7 @@ DataAccessObject.updateOrCreate = DataAccessObject.upsert = function upsert(data var context = { Model: Model, data: data, + isNewInstance: info && info.isNewInstance, hookState: ctx.hookState, options: options }; diff --git a/test/persistence-hooks.suite.js b/test/persistence-hooks.suite.js index 897933d0..050a7fa2 100644 --- a/test/persistence-hooks.suite.js +++ b/test/persistence-hooks.suite.js @@ -1722,7 +1722,8 @@ module.exports = function(dataSource, should) { if (dataSource.connector.updateOrCreate) { observedContexts.should.eql(aTestModelCtx({ - data: { id: 'new-id', name: 'a name' } + data: { id: 'new-id', name: 'a name' }, + isNewInstance: true, })); } else { observedContexts.should.eql(aTestModelCtx({ @@ -1750,7 +1751,8 @@ module.exports = function(dataSource, should) { data: { id: existingInstance.id, name: 'updated name' - } + }, + isNewInstance: false })); } else { // For Unoptimized connector, the callback function `pushContextAndNext`