I have a an AR object model/table with a bit field of size 7. When
creating a new record rails has no problem if I just specify an integer
value in place of the bit field value (ideally it should be able to
handle b'1010101' as mysql does). Pulling the data out of the table
is a bit strange. I've been experimenting with
model.field.unpack('B*'). This should return all the bits in the
field, which I would assume is a string of 7 bits. However, this isn't
the case. Instead it returns a string of 8 bits. Using unpack('B7')
it chops off the least significant bit. Apparently there is a '0' bit
appended to the bit string in the place of the most significant bit.
I'm not sure if this is an issue with Rails' ActiveRecord, ruby, mysql
5, my ignorance or some combination of these.
Does anyone have any ideas or an explanation?