-
Notifications
You must be signed in to change notification settings - Fork 798
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
Update callbacks do not use as_indexed_json #37
Comments
+1 |
If we did want to make this work beyond trivial cases perhaps ES::Model should be asking the instance for updates rather than taking them out of changed attributes. There could always be a default implementation that just returned the changed attributes. On the otherhand perhaps the pragmatic thing is to just write your own update_document if you have that need. |
Please see #5 . |
D'oh - I'm a dummy. Given that the conclusion has been reached that the library shouldn't be trying to do anything smart in this case, perhaps the documentation should reflect this? |
+1 to document it's behavior in README. I had custom callbacks, and it would not update the serialized json field. The solution was to just use es.index_document on the models that have serialized fields versus update_document. Its a bit of a performance killer most likely, but it works and is only updated on a cron job every 20 mins. |
@fcheung I'm still thinking whether we can somehow intercept the changes better, but I don't think so. It would be nice to check whether the model itself (and not the proxy) implements the |
…serialized during update Previously, the `update_document` method simply intercepted the changes to the model, via the `@__changed_attributes` variable, and used these directly. This caused models with a custom serialization method to be incorrectly serialized, namely unwanted attributes were added. This patch looks for `as_indexed_json` defined on the model, and when it finds it, filters the changed attributes through the keys. Closes #75 Related: * #59 * #57 * #52 * #40 * #37 * #5
@fcheung Actually, the simple case was quite simple to solve, unless I'm missing something very obvious -- please check the linked commit. |
The update callbacks mine
changed_attributes
directlyThis has 2 consequences for people with a custom
as_indexed_json
as_indexed_json
omits some attributes then they will be included when a record is updated in this wayPerhaps the documentation should highlight this?
The text was updated successfully, but these errors were encountered: