Skip to content

Commit 77641a8

Browse files
committed
Fixes bug when creating Models without all data (#69)
Getters/setters for properties would not be correctly defined
1 parent 6ae390a commit 77641a8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/Instance.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ function Instance(opts) {
236236
addInstanceProperty(opts.id);
237237
}
238238

239+
for (var k in opts.properties) {
240+
if (opts.properties.hasOwnProperty(k) && !opts.data.hasOwnProperty(k) && k != opts.id) {
241+
opts.data[k] = null;
242+
}
243+
}
244+
239245
for (var k in opts.data) {
240246
if (!opts.data.hasOwnProperty(k)) continue;
241247
if (!opts.properties.hasOwnProperty(k) && k != opts.id && opts.association_properties.indexOf(k) == -1) {

0 commit comments

Comments
 (0)