Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/mysql-binuuid/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def cast(value)
# it to the database.
def serialize(value)
return if value.nil?
undashed_uuid = strip_dashes(value)
if value.is_a?(String) && value.encoding == Encoding::ASCII_8BIT && strip_dashes(value).length != 32
undashed_uuid = value.unpack1('H*')
else
undashed_uuid = strip_dashes(value)
end

# To avoid SQL injection, verify that it looks like a UUID. ActiveRecord
# does not explicity escape the Binary data type. escaping is implicit as
Expand Down