Fix incompatibility between different connectors PR#938

* Fix incompatibility for replace methods between different connectors.
This commit is contained in:
Amir Jafarian 2016-05-20 11:40:17 -04:00
parent a9f69bcbc6
commit 0d5cff5a0a
2 changed files with 12 additions and 19 deletions

View File

@ -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;

View File

@ -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();
});