mysql-binuuid-rails icon indicating copy to clipboard operation
mysql-binuuid-rails copied to clipboard

FIX: Serialization Error when the value is an empty string

Open sbhawsingka opened this issue 2 years ago • 1 comments

When we have nil for a foreign key, Rails converts it to an empty string before assigning the attributes to the model and hence it sends an empty string for serialization. This returns MySQLBinUUID::InvalidUUID, "#{value} is not a valid UUID", and this PR aims to fix that.

sbhawsingka avatar Feb 08 '23 11:02 sbhawsingka

Hi @sbhawsingka 👋 Thank you for contributing!

Could you please add a test case that reproduces the issue you're experiencing? I was under the impression that if a column is NULL in the database, Rails will keep it nil. Having a test case may help understand.

String#blank? is part of ActiveSupport, but ActiveSupport is not a dependency of this gem, so it can't be used. Ruby's .empty? can.

markoudev avatar Feb 08 '23 12:02 markoudev