Merge branch 'release/1.3.4' into production

This commit is contained in:
Raymond Feng 2014-02-25 10:03:08 -08:00
commit 5cbc1e1710
3 changed files with 29 additions and 3 deletions

View File

@ -876,8 +876,9 @@ DataAccessObject.prototype.updateAttributes = function updateAttributes(data, cb
var typedData = {}; var typedData = {};
for (var key in data) { for (var key in data) {
// Convert the properties by type
inst[key] = data[key]; inst[key] = data[key];
typedData[key] = inst.__data[key]; typedData[key] = inst[key];
} }
inst._adapter().updateAttributes(model, getIdValue(inst.constructor, inst), inst.constructor._forDB(typedData), function (err) { inst._adapter().updateAttributes(model, getIdValue(inst.constructor, inst), inst.constructor._forDB(typedData), function (err) {
@ -886,7 +887,6 @@ DataAccessObject.prototype.updateAttributes = function updateAttributes(data, cb
for (var key in data) { for (var key in data) {
inst.__dataWas[key] = inst.__data[key]; inst.__dataWas[key] = inst.__data[key];
} }
;
} }
done.call(inst, function () { done.call(inst, function () {
saveDone.call(inst, function () { saveDone.call(inst, function () {

View File

@ -1,6 +1,6 @@
{ {
"name": "loopback-datasource-juggler", "name": "loopback-datasource-juggler",
"version": "1.3.3", "version": "1.3.4",
"description": "LoopBack DataSoure Juggler", "description": "LoopBack DataSoure Juggler",
"keywords": [ "keywords": [
"StrongLoop", "StrongLoop",

View File

@ -486,6 +486,32 @@ describe('DataSource define model', function () {
}); });
it('should update the instance with unknown properties', function (done) {
var ds = new DataSource('memory');// define models
Post = ds.define('Post', {
title: { type: String, length: 255, index: true },
content: { type: String }
});
Post.create({title: 'a', content: 'AAA'}, function (err, post) {
post.updateAttributes({title: 'b', xyz: 'xyz'}, function (err, p) {
should.not.exist(err);
p.id.should.be.equal(post.id);
p.content.should.be.equal(post.content);
p.xyz.should.be.equal('xyz');
Post.findById(post.id, function (err, p) {
p.id.should.be.equal(post.id);
p.content.should.be.equal(post.content);
p.xyz.should.be.equal('xyz');
p.title.should.be.equal('b');
done();
});
});
});
});
it('injects id by default', function (done) { it('injects id by default', function (done) {
var ds = new ModelBuilder(); var ds = new ModelBuilder();