It seems that rails uses the newer psych
YAML mechanism by psych
, the older syck
yaml mechanism does not output !binary
Binary keys. If you just want to test it in the console, you can switch to the old Yamal engine as a temporary solution:
> y User.first User Load (0.0ms) SELECT "users".* FROM "users" LIMIT 1 --- !ruby/object:User attributes: !binary "aWQ=": 1 !binary "bmFtZQ==": Example User !binary "ZW1haWw=": user@example.com > YAML::ENGINE.yamler= 'syck' => "syck" > y User.first User Load (1.0ms) SELECT "users".* FROM "users" LIMIT 1 --- !ruby/object:User attributes: id: 1 name: Example User email: user@example.com
You will only need to do this when the keys of the name / attribute of the ActiveRecord column are encoded using Encoding::ASCII_8BIT
, which, it seems to me, only happens with SQLite.
Update:
After posting this answer, SQLite3 stone has been fixed to return utf8 for column names . Make sure you are using version 1.3.6 (or higher) in sqlite3 stone. Then the default mechanism / new psych yaml (which also supports unicode output for humans) will work without problems:
> y User.first User Load (0.0ms) SELECT "users".* FROM "users" LIMIT 1 EXPLAIN (0.0ms) EXPLAIN QUERY PLAN SELECT "users".* FROM "users" LIMIT 1 EXPLAIN for: SELECT "users".* FROM "users" LIMIT 1 0|0|0|SCAN TABLE users (~1000000 rows) --- !ruby/object:User attributes: id: 1 name: irmΓ£o email: user@example.com
source share