mysql icon indicating copy to clipboard operation
mysql copied to clipboard

considering BIT as a Tiny int value

Open odahcam opened this issue 9 months ago • 3 comments

This is motivated by:

BIT values in MySQL are closer to integers. Although they’re stored as binary data, they represent numeric bit-fields and are used in bitwise operations, which aligns them more with integers than with strings. (https://github.com/amphp/mysql/issues/137#issuecomment-2755789840)

odahcam avatar Mar 26 '25 21:03 odahcam

A BIT field is a binary data type. Simply casting to an integer is insufficient. unpack() will be necessary to convert the value to an integer.

The other binary field types are returned as strings. While I can see the logic in returning a BIT field as an integer, this would be a BC break to anyone who is doing the conversion to an integer themselves.

trowski avatar Mar 28 '25 22:03 trowski

@trowski I'd say converting to int is the right thing to do, given that this is what php-src also does. But yes, it's unfortunate that it's a BC break.

bwoebi avatar Mar 29 '25 02:03 bwoebi

Hey thank you for your attention! I understand your concerns and I'm glad this is somewhat relevant to you. Let me know if any further steps shall be taken, I'm glad to help.

odahcam avatar Mar 31 '25 17:03 odahcam