-
Notifications
You must be signed in to change notification settings - Fork 51
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
Updating does not fire callbacks with updated attributes #87
Comments
Ping @benedikt |
Hi @abinoda! I can confirm that this doesn't work as expected and was able to trace it down to this line:
When using Maybe it's save to remove that parameter? I don't know to be honest 😄 |
@benedikt Would adding a
I'm not familiar with this code but just an idea. |
No, |
@benedikt Should the README be updated? See related – https://github.com/zdennis/activerecord-import#callbacks |
Or I wonder if all callback support should just be removed since they don't work predictably or consistently? Instead of there being ambiguous partial support? That'd be easier and less error-prone for developers, avoiding scenarios like what occurred here for me. |
I have this vague memory that we added callback support in order to have timestamps work like you expect, but I'm not sure. I'm all for removing callback support if we can just make sure timestamps work. |
@jesjos The timestamps don't rely on callbacks right now: https://github.com/jesjos/active_record_upsert/blob/master/lib/active_record_upsert/active_record/timestamp.rb However, I still think this isn't a problem with callbacks, but with the way The initial problem can be easily bypassed by explicitly passing Car.upsert!(internal_id: 1, first_val: 1, second_val: 2)
car = Car.upsert!(internal_id: 1, first_val: 2, second_val: 2, sum: nil)
car.sum #=> 4 |
Just to provide some more color to this, I'm currently looking at using https://github.com/attr-encrypted/attr_encrypted. I'm thinking through whether or not it works out of the box with It would be nice to be able to say "oh, So personally, I'd vote for removing all callback support in a breaking change to simplify this library. |
When updating a record via
upsert!
, callbacks do not use the latest attribute values. See example below:I think its related to this commit.
The text was updated successfully, but these errors were encountered: