diff --git a/lib/dao.js b/lib/dao.js index 50a0c273..35a79244 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -393,7 +393,7 @@ DataAccessObject.updateOrCreate = DataAccessObject.upsert = function upsert(data function done(err, data) { var obj; if (data && !(data instanceof Model)) { - inst._initProperties(data); + inst._initProperties(data, { persisted: true }); obj = inst; } else { obj = data; diff --git a/test/manipulation.test.js b/test/manipulation.test.js index 875ccf18..16eddd97 100644 --- a/test/manipulation.test.js +++ b/test/manipulation.test.js @@ -567,6 +567,15 @@ describe('manipulation', function () { }); }); }); + + it('should allow save() of the created instance', function(done) { + Person.updateOrCreate( + { id: 'new-id', name: 'a-name' }, + function(err, inst) { + if (err) return done(err); + inst.save(done); + }); + }); }); describe('findOrCreate', function() {