has_changed() and old_values() buggy #23

clintongormley opened this Issue Nov 16, 2012 · 0 comments

1 participant


The has_changed() and old_values() functionality relies on triggers being called whenever a setter or clearer is called on an attribute.

However, this doesn't work for any complex value (eg hashref/arrayref) as the ref itself might change, without the contents being altered.

Also, these triggers aren't being applied to any attributes included from roles.

Keeping track of changing attributes adds quite a lot of overhead and impacted performance, but we currently have to do it because save() only saves if the object has changed.

@clintongormley clintongormley added a commit that closed this issue Nov 16, 2012
@clintongormley BREAKING CHANGE: The has_changed()/old_values() functionality no longer
works by wrapping setters/clearers. Instead, we calculate the changed
keys on the fly when old_values() is called.  This checks actual
values to be stored in ES, so is correct for complex data structures as
well as simple scalars. old_value() has been removed because it
needs to call old_values(), so it is more performant (esp when checking
multiple attributes) to just call old_values() yourself.
Also, save() no longer checks if the object has_changed() before saving.

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