Don't change iv field when value is the same#284
Don't change iv field when value is the same#284arthurnn wants to merge 1 commit intoattr-encrypted:masterfrom
Conversation
``` user = User.new(name: 'hi') user.name = 'hi' ``` That code would generate two different ivs. At first look that is not an issue, but when using attr_encrypted combined with ActiveRecord this could impose some issues. Like extra writes to the db. Also, marking some attributes as dirty, when they were actually not changed. [fixes attr-encrypted#216]
|
This duplicates #216. Please see my response as to why this behavior exists here: #216 (comment) |
(Copying your answer from the other issue) I think it is sensible the use cases where you want to force an update, for the use cases you described. However, I believe when someone is doing so, they will want to force that behaviour. So the default, in my opinion, should be to not update if the value is the same. |
|
When updating a single attribute all encrypted attributes of that class are changed also. This is unwanted default behaviour when using audited recording all changes made by some user. This default behavior could be a configurable option. |
That code would generate two different ivs.
At first look that is not an issue, but when using attr_encrypted combined
with ActiveRecord this could impose some issues. Like extra writes to the db.
Also, marking some attributes as dirty, when they were actually not changed.
[fixes #216]
also fixes https://stackoverflow.com/questions/47422328/attr-encrypted-updating-all-encrypted-fields-although-i-only-changed-one