Closed airblade closed 7 years ago
The generator coerces the empty string:
# Here value is "" and type is "string"
v = SymmetricEncryption::Coerce.coerce(value, :#{type})
– and the coercion turns the empty string into nil:
return if blank?(value)
Shouldn't "coercing" a :string
attribute to a string leave it untouched? And, in this case, leave an empty string as an empty string?
Have noticed the same behavior and agree the appropriate behavior is to leave an empty string as an empty string after coercion.
Agreed, looked at briefly but looks like it is deep in the Coerce code somewhere.
Definitely want this to be fixed though as converting nil to '' is not expected behavior.
Thanks!
Thanks.
On Mon, Jul 24, 2017 at 3:48 AM, Andy Stewart notifications@github.com wrote:
Thanks!
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rocketjob/symmetric-encryption/issues/77#issuecomment-317358653, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKr1ay8fQC2_iLqSBZ-PKHX9Ecorfuyks5sRFpagaJpZM4NcsJw .
I have a Rails 5 app with a model which has an encrypted attribute.
When I set
foo
to an empty string and save, the system tries to updatefoo
in the database with anil
value. I would expect it to send an empty string to the database, notnil
.I'm using symmetric-encryption 3.9.0, rails 5.0.1.