Skip to content

Commit c2a7167

Browse files
committed
Fixes passing unknown properties to new instances (fixes dresende#178)
1 parent 151a7b8 commit c2a7167

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/Model.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ function Model(opts) {
3030
if (!inst_opts) {
3131
inst_opts = {};
3232
}
33+
34+
for (var k in data) {
35+
if (k != "extra_field" && !opts.properties.hasOwnProperty(k) && opts.keys.indexOf(k) == -1
36+
&& association_properties.indexOf(k) == -1) {
37+
delete data[k];
38+
}
39+
}
40+
3341
var instance = new Instance({
3442
id : opts.id,
3543
keys : opts.keys,

0 commit comments

Comments
 (0)