Merge pull request #938 from strongloop/replace_incompatibility_fix

Fix incompatibility between different connectors for replace methods
This commit is contained in:
Amir-61 2016-05-28 09:06:34 -04:00
commit 1f94f63bc1
2 changed files with 12 additions and 19 deletions

View File

@ -2722,13 +2722,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;

View File

@ -800,8 +800,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');
@ -830,8 +830,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');
@ -858,8 +858,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);
@ -887,8 +887,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);
@ -992,7 +992,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');
@ -1012,7 +1012,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');
@ -1029,7 +1029,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();
});
@ -1041,7 +1041,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();
});