You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A problem arises if I try to immediately decrypt a column that I have set using attr_encrypted. It returns the value I've set, but this value hasn't gone through the CustomMarshal when I expect that it would.
# abc is the recordnew_value=[{hello: 'how are you doing'}]# CustomMarshal.dump is called; this works like I expect it to.abc.data=new_value# Fails: abc.data has gone through the marshaler – new_value hasn'texpect(abc.data).to_noteq(new_value)# Fails: forcing new_value through the marshaler should make it equal abc.datamarshalled_value=CustomMarshal.dump(new_value)expect(abc.data).toeq(CustomMarshal.load(marshalled_value))# Passes: the above tests will pass if I reload the recordabc.reloadexpect(abc.data).to_noteq(new_value)expect(abc.data).toeq(CustomMarshal.load(marshalled_value))
The culprit could be this line, but it looks like this behavior is intentional. Are my expectations here wrong? I feel like if I set a custom marshaler in the options, it should always use the marshaler to load and dump the values. Otherwise, after I set the attribute on the record, I have to explicitly reload it for the marshaller to actually work.
The text was updated successfully, but these errors were encountered:
I want to add that using ActiveRecord's #serialize does what I expect it to – I don't have to reload the record for it to go through the custom marshaler.
I have a column encrypted by
attr_encrypted
, let's call this columndata
. I also have a custom Marshaler that loads/dumps data in the column.A problem arises if I try to immediately decrypt a column that I have set using
attr_encrypted
. It returns the value I've set, but this value hasn't gone through the CustomMarshal when I expect that it would.The culprit could be this line, but it looks like this behavior is intentional. Are my expectations here wrong? I feel like if I set a custom marshaler in the options, it should always use the marshaler to load and dump the values. Otherwise, after I set the attribute on the record, I have to explicitly reload it for the marshaller to actually work.
The text was updated successfully, but these errors were encountered: