We have been using Blazer with some tables that have binary UUID columns.
When returning data that has binary data and plain text data it raises an error.
e.g. running the following SQL with a MySQL data source
select unhex("F6"), 123
raises
Encoding::UndefinedConversionError - "\xF6" from ASCII-8BIT to UTF-8:
This only happens if
the binary column is the first column returned
there's no non-binary columns after the binary columns
e.g. these all work
select unhex("F6"); /* this works */
select unhex("F6"), unhex("F6"); /* this works */
select 123, unhex("F6"); /* this works */
select 123, unhex("F6"), 123; /* this works */
We have found this monkey patch fixes the issue but it's not ideal.
Adding this to config/initializers/blazer.rb
module SwrveBlazer
module BaseHelper
def blazer_format_value(key, value)
format_value = super(key, value)
format_value.respond_to?(:force_encoding) ? format_value.force_encoding(Encoding::UTF_8) : format_value
end
end
end
Blazer::BaseHelper.prepend(SwrveBlazer::BaseHelper)
We have been using Blazer with some tables that have binary UUID columns. When returning data that has binary data and plain text data it raises an error.
e.g. running the following SQL with a MySQL data source
raises
This only happens if
e.g. these all work
We have found this monkey patch fixes the issue but it's not ideal. Adding this to
config/initializers/blazer.rb