mysql-binuuid-rails
mysql-binuuid-rails copied to clipboard
FIX: Serialization Error when the value is an empty string
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.
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.