Messages "Binary data inserted for `string`", but encoding looks OK to me

This is an excerpt from a rails console session:

2.1.1 :011 > x=User.new({name: ‘x’, email: ‘[email protected]’, password:
‘xxxxxxxx’, password_confirmation: ‘xxxxxxxx’})
=> #<User id: nil, name: “x”, email: “[email protected]”, created_at: nil,
updated_at: nil, password_digest:
“$2a$10$sOP18GHU/e4Q.yTT.6tTguLeqR4vN1QCXTZU6mMxERO…”, remember_token:
nil, admin: false>

2.1.1 :012 > x.save
(0.2ms) begin transaction
Binary data inserted for string type on column name
User Exists (12.9ms) SELECT 1 AS one FROM “users” WHERE
“users”.“name” = ‘x’ LIMIT 1
Binary data inserted for string type on column email
User Exists (0.5ms) SELECT 1 AS one FROM “users” WHERE
LOWER(“users”.“email”) = LOWER(‘[email protected]’) LIMIT 1
Binary data inserted for string type on column email
Binary data inserted for string type on column name
Binary data inserted for string type on column password_digest
SQL (30.4ms) INSERT INTO “users” (“created_at”, “email”, “name”,
“password_digest”, “remember_token”, “updated_at”) VALUES (?, ?, ?, ?,
?, ?) [[“created_at”, “2014-07-06 09:45:54.350309”], [“email”,
[email protected]”], [“name”, “x”], [“password_digest”,
“$2a$10$sOP18GHU/e4Q.yTT.6tTguLeqR4vN1QCXTZU6mMxEROS.YKWJ/5gq”],
[“remember_token”, “182afad1b65b10a7aa6f9869e811e6671f0d32c8”],
[“updated_at”, “2014-07-06 09:45:54.350309”]]
(12.3ms) commit transaction
=> true

We can see that everything works, and indeed, x.errors shows an empty
message list. However, I wonder what the warnings (?) “Binary data
inserted…” mean.

When I google this subject, the usual explanation is an encoding issue.
In my case, the data contain just 8 bit ASCII, as we can see here:

2.1.1 :014 > x.name.encoding
=> #Encoding:ASCII-8BIT

I probably don’t have to worry about these messages, as my user is
created, but I would like to know out of curiosity…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs