propertyChanged Doesn't work #129

Closed
tanema opened this Issue Oct 1, 2012 · 6 comments

Comments

Projects
None yet
4 participants

tanema commented Oct 1, 2012

The source for the function is this

 function propertyChanged(attr) {
    return this['_' + attr] !== this[attr + '_was'];
 };

However this[attr + '_was'] is never defined so propertychanged always returns true

Collaborator

anatoliychakkaev commented Oct 2, 2012

This is strange because all tests passed. Could you provide isolated test
case to help me identify issue?

On Tue, Oct 2, 2012 at 1:00 AM, Tim Anema notifications@github.com wrote:

The source for the function is this

function propertyChanged(attr) {
return this['_' + attr] !== this[attr + '_was'];
};

However this[attr + '_was'] is never defined so propertychanged always
returns true


Reply to this email directly or view it on GitHubhttps://github.com/1602/jugglingdb/issues/129.

tanema commented Oct 2, 2012

It will take me a little while to do that, but in the mean time I will put all my details, I was using it in a railwayjs app and I specifically using it in a beforeUpdate callback which I am starting to think might be the actual problem. I am using Mongodb as well with the mongoose adapter

Contributor

syadykin commented Oct 4, 2012

Same for me. Even freshly fetched object already have all fields marked as changed (_attr_was is undefined). Same env — railwayjs + mongoose

Contributor

syadykin commented Oct 4, 2012

It happens because mongoose document have no own properties (it have only setters/getters) so https://github.com/1602/jugglingdb/blob/master/lib/abstract-class.js#L101 doesn'n execute. The fix could be toObject called on each document somewhere in mongoose adapter.

Collaborator

anatoliychakkaev commented Oct 6, 2012

Guys, any reasons to use mongoose adapter? From jugglingdb point of view it
does the same as mongodb adapter. Why not just use 'mongodb' adapter? For
mongoose ORM we can build separate module which will publish pure mongoose
models to railway-managed project. What do you think?

On Fri, Oct 5, 2012 at 1:23 AM, tosick notifications@github.com wrote:

It happens because mongoose document have no own properties (it have only
setters/getters) so
https://github.com/1602/jugglingdb/blob/master/lib/abstract-class.js#L101doesn'n execute. The fix could be toObject called on each document
somewhere in mongoose adapter.

Reply to this email directly or view it on GitHubhttps://github.com/1602/jugglingdb/issues/129#issuecomment-9157739.

Owner

1602 commented Jan 22, 2013

This works now, not sure when it was fixed. Please reopen ticket is someone still have issues.

1602 closed this Jan 22, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment