anlek/mongify

UTF8 Problem with Postgresql

Closed this issue · 3 comments

Hi,
I have the same issue but in my case i'm using Postgresql it shows me this :

/Library/Ruby/Gems/2.0.0/gems/bson-1.10.2/lib/bson/bson_c.rb:20:in `serialize': String not valid UTF-8
(BSON::InvalidStringEncoding)

I added the "encoding "utf8" in the database.config" but it doesn't work.

Thanks for the attention

In my case i'm dealing with binary format of jpg data stored in postgresql, so when mongify convert the :binary -> String it will be not supported by mongodb(UTF8).

Can i change the behavior of :binary --> jpg (not string) ?
Thank you.

Hmm, it's not something I'm too aware of. I haven't tried to store binary data in MongoDB. However if you want to add a pull request, that would be great!

I ran into the same issue when converting Piwik data, the IP is stored as binary data - a quick fix is to convert the data to a hex string in line 267 of column.rb:

ActiveRecord::ConnectionAdapters::Column.binary_to_string(value.unpack('H*').join)