On Monday, August 28, 2017 at 5:16:21 AM UTC-7, Satyanarayana Gandham wrote:
>
> Hi,
>
> Recently I have updated the sequel version from '4.36.0' to '4.45.0'. 
> After updating, "force_encoding" plugin is not working on columns of type 
> "text" (Migration: "String :name, text: true").
>
> Found that the "force_encoding" plugin is updated and now doesn't force 
> encode Sequel::SQL::Blob objects.
>
> One solution I found is to convert the text columns type to varchar 
> columns by mentioning the size (Migration: "String :name, size: 1000"). Is 
> this the proper way? May I know the reasons for stopping the force encoding 
> of Sequel::SQL::Blob objects?
>

It's expected that blobs will not have the encoding forced.  This is 
because they are supposed to contain arbitrary data, not text in a specific 
encoding (blob standing for Binary Large OBject).

Unfortunately, MySQL basically treats text as an alias for blob.  I'd 
consider that a bug, but it's been that way for a long time.

As a workaround, you can do:

def name=(v)
  super.force_encoding(model.forced_encoding)
end

def force_hash_encoding(row)
  row[:name].force_encoding(model.forced_encoding)
  super
end

I'd consider a pull request to add an option to allow the historical 
behavior of force encoding blobs.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to