Skip to content

Conversation

odahcam
Copy link

@odahcam odahcam commented Mar 26, 2025

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.
(#137 (comment))

odahcam added 2 commits March 26, 2025 18:42
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. 
(amphp#137 (comment))
I didn't noticed at first but it was breaking some functionality.
@trowski
Copy link
Member

trowski commented Mar 28, 2025

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.

@bwoebi
Copy link
Member

bwoebi commented Mar 29, 2025

@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.

@odahcam
Copy link
Author

odahcam commented Mar 31, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants