Make sure falsy value is kept for properties not predefined
This commit is contained in:
parent
07e65d6618
commit
fcd8ed984c
|
@ -151,7 +151,8 @@ ModelBaseClass.prototype._initProperties = function (data, options) {
|
|||
} else {
|
||||
// Un-managed property
|
||||
if (strict === false || self.__cachedRelations[p]) {
|
||||
self[p] = self.__data[p] = propVal || self.__cachedRelations[p];
|
||||
self[p] = self.__data[p] =
|
||||
(propVal !== undefined) ? propVal : self.__cachedRelations[p];
|
||||
} else if (strict === 'throw') {
|
||||
throw new Error('Unknown property: ' + p);
|
||||
}
|
||||
|
|
|
@ -28,12 +28,13 @@ describe('ModelBuilder define model', function () {
|
|||
modelBuilder.models.should.be.a('object').and.have.property('User', User);
|
||||
modelBuilder.definitions.should.be.a('object').and.have.property('User');
|
||||
|
||||
var user = new User({name: 'Joe', age: 20});
|
||||
var user = new User({name: 'Joe', age: 20, xyz: false});
|
||||
|
||||
User.modelName.should.equal('User');
|
||||
user.should.be.a('object').and.have.property('name', 'Joe');
|
||||
user.should.have.property('name', 'Joe');
|
||||
user.should.have.property('age', 20);
|
||||
user.should.have.property('xyz', false);
|
||||
user.should.not.have.property('bio');
|
||||
done(null, User);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue