diff --git a/lib/abstract-class.js b/lib/abstract-class.js index 8934fc26..f4cd0be4 100644 --- a/lib/abstract-class.js +++ b/lib/abstract-class.js @@ -595,7 +595,7 @@ AbstractClass.prototype.fromObject = function (obj) { * @return Boolean */ AbstractClass.prototype.propertyChanged = function propertyChanged(attr) { - return this['_' + attr] !== this[attr + '_was']; + return this.hasOwnProperty(attr + '_was') && this['_' + attr] !== this[attr + '_was']; }; /** diff --git a/test/common_test.js b/test/common_test.js index 723f1bea..4a6c5685 100644 --- a/test/common_test.js +++ b/test/common_test.js @@ -315,7 +315,7 @@ function testOrm(schema) { test.ok(post.propertyChanged('content')); post.reload(function (err, post) { test.equal(post.title, 'New title'); - test.ok(!post.propertyChanged('title')); + test.ok(!post.propertyChanged('title'), 'title not changed'); test.equal(post.content, 'content', 'real value turned back'); test.ok(!post.propertyChanged('content'), 'content unchanged'); test.done();