From 0d5cff5a0aea4bd30b526573ec0f128b6031a596 Mon Sep 17 00:00:00 2001 From: Amir Jafarian Date: Fri, 20 May 2016 11:40:17 -0400 Subject: [PATCH] Fix incompatibility between different connectors PR#938 * Fix incompatibility for replace methods between different connectors. --- lib/dao.js | 7 ------- test/manipulation.test.js | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/lib/dao.js b/lib/dao.js index b3d5da31..2c8f543b 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -2699,13 +2699,6 @@ DataAccessObject.replaceById = function(id, data, options, cb) { } function callConnector() { - var idNames = Model.definition.idNames(); - var propKeys = Object.keys(Model.definition.properties); - var nonIdsPropKeys = propKeys.filter(function(i) { return idNames.indexOf(i) < 0; }); - for (var i = 0; i < nonIdsPropKeys.length; i++) { - var p = nonIdsPropKeys[i]; - inst[p] = null; - } copyData(data, inst); var typedData = convertSubsetOfPropertiesByType(inst, data); context.data = typedData; diff --git a/test/manipulation.test.js b/test/manipulation.test.js index 32a36b1c..7f46cb21 100644 --- a/test/manipulation.test.js +++ b/test/manipulation.test.js @@ -796,8 +796,8 @@ describe('manipulation', function() { p.id.should.equal(created.id); p.should.not.have.property('_id'); p.title.should.equal('b'); - p.should.not.have.property(p.content); - p.should.not.have.property(p.comments); + p.should.have.property('content', undefined); + p.should.have.property('comments', undefined); return Post.findById(created.id) .then(function(p) { p.should.not.have.property('_id'); @@ -826,8 +826,8 @@ describe('manipulation', function() { p.id.should.equal(created.id); p.should.not.have.property('_id'); p.title.should.equal('b'); - p.should.not.have.property(p.content); - p.should.not.have.property(p.comments); + p.should.have.property('content', undefined); + p.should.have.property('comments', undefined); return Post.findById(created.id) .then(function(p) { p.should.not.have.property('_id'); @@ -854,8 +854,8 @@ describe('manipulation', function() { p.id.should.equal(post.id); p.should.not.have.property('_id'); p.title.should.equal('b'); - p.should.not.have.property(p.content); - p.should.not.have.property(p.comments); + p.should.have.property('content', undefined); + p.should.have.property('comments', undefined); Post.findById(post.id, function(err, p) { if (err) return done(err); p.id.should.eql(post.id); @@ -883,8 +883,8 @@ describe('manipulation', function() { p.id.should.equal(post.id); p.should.not.have.property('_id'); p.title.should.equal('b'); - p.should.not.have.property(p.content); - p.should.not.have.property(p.comments); + p.should.have.property('content', undefined); + p.should.have.property('comments', undefined); Post.findById(post.id, function(err, p) { if (err) return done(err); p.id.should.eql(post.id); @@ -988,7 +988,7 @@ describe('manipulation', function() { should.exist(p); p.should.be.instanceOf(Post); p.title.should.equal('b'); - p.should.not.have.property('content', undefined); + p.should.have.property('content', undefined); return Post.findById(postInstance.id) .then(function(p) { p.title.should.equal('b'); @@ -1008,7 +1008,7 @@ describe('manipulation', function() { should.exist(p); p.should.be.instanceOf(Post); p.title.should.equal('b'); - p.should.not.have.property('content', undefined); + p.should.have.property('content', undefined); return Post.findById(postInstance.id) .then(function(p) { p.title.should.equal('b'); @@ -1025,7 +1025,7 @@ describe('manipulation', function() { if (err) return done(err); p.replaceAttributes({ title: 'b' }, function(err, p) { if (err) return done(err); - p.should.not.have.property('content', undefined); + p.should.have.property('content', undefined); p.title.should.equal('b'); done(); }); @@ -1037,7 +1037,7 @@ describe('manipulation', function() { if (err) return done(err); p.replaceAttributes({ title: 'b' }, { validate: false }, function(err, p) { if (err) return done(err); - p.should.not.have.property('content', undefined); + p.should.have.property('content', undefined); p.title.should.equal('b'); done(); });