Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isChanged meaning #37

Closed
wishper opened this issue Jun 11, 2013 · 2 comments
Closed

isChanged meaning #37

wishper opened this issue Jun 11, 2013 · 2 comments

Comments

@wishper
Copy link

wishper commented Jun 11, 2013

Should isChanged return true only if the record has changed?
The reason of my question is the following: a simple query returns records that are 'changed' (to my great surprise): is really this the desired behaviour or did I miss something obvious?

it ('joli.record.isChanged()', function() {
    var city = models.city.findOneBy('name', 'New York')
    expect(city.isChanged()).toBeFalsy();
});
@xavierlacot
Copy link
Owner

isChanged() returns true if one of the properties of a record has been changed. It may be useful to check if a record has been modified and know if it needs to be persisted or not.

@wishper
Copy link
Author

wishper commented Jun 26, 2013

thank you for the reply. I'm sorry, but I'm not sure you understood my
question.

on 25/06/2013 17:55, Xavier Lacot wrote:

|isChanged()| returns true if one of the properties of a record has
been changed.

Changed since when? I suppose since last persist

It may be useful to check if a record has been modified and know if it
needs to be persisted or not.

Luckily, It it the way I'm using it, but...
IMHO, a record just read from DB needs not to be persisted again. So, again:
why isChanged()==true for a record returned by a query (and not modified
by anyone)?

for details, read the snipped in the op. The test does not pass.
Just in case joli's logic is correct, can you please point me which is
the 'change' that needs to be persisted?

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants