datamapper / do

DataObjects
147 stars 74 forks source link

UTF-8-MB4 issues #89

Closed tiagocasanovapt closed 8 years ago

tiagocasanovapt commented 8 years ago
# coding: utf-8

# Ruby: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]

require 'dm-core'
require 'dm-migrations'

class Foo
  include DataMapper::Resource
  property :id, Serial
  property :value, String
end

DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, {"adapter"=>"mysql", "encoding"=>"UTF-8-MB4", "database"=>"vendder_test", "username"=>"root", "host"=>"127.0.0.1"})
DataMapper.auto_migrate!

Foo.create(:value => "A pile of poop 💩💩💩")
p Foo.first.value
p Foo.first.value.encoding.name

# => "A pile of poop \xF0\x9F\x92\xA9\xF0\x9F\x92\xA9\xF0\x9F\x92\xA9"
# => "ASCII-8BIT"
# This should be "UTF-8 / UTF-8-MB4"

Setting the encoding for UTF-8-MB4 doesn't seem to properly work when we try to read the values from the DB. Apologies if this is the wrong repository for this issue.

dbussink commented 8 years ago

Opened #89 to fix this issue.