ruby - Mysql2: How do I read a bit column correctly? -
mysql2 reads in bit columns strings default.
my schema:

in ruby:

how read them bytes?
there may better way deal w/it in mysql library, in experience, strings how ruby deals binary data. binary file reader methods same thing.
check out #unpack method. can stuff like:
[16] pry(main)> bytes = "\x00\x01\x02" => "\u0000\u0001\u0002" [17] pry(main)> bytes.unpack('c*') => [0, 1, 2]
Comments
Post a Comment