Ronald Fischer
2014-Jul-06 09:57 UTC
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: 'x@example.org',
password:
'xxxxxxxx', password_confirmation: 'xxxxxxxx'})
=> #<User id: nil, name: "x", email: "x@example.org",
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('x@example.org')
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",
"x@example.org"], ["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....
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/b95345b6a72a557a92db9bde462e471d%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.