Skip to content

Return BIT columns as integer#138

Draft
odahcam wants to merge 2 commits into
amphp:3.xfrom
odahcam:patch-2
Draft

Return BIT columns as integer#138
odahcam wants to merge 2 commits into
amphp:3.xfrom
odahcam:patch-2

Conversation

@odahcam

@odahcam odahcam commented Mar 26, 2025

Copy link
Copy Markdown

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

trowski commented Mar 28, 2025

Copy link
Copy Markdown
Member

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

bwoebi commented Mar 29, 2025

Copy link
Copy Markdown
Member

@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

odahcam commented Mar 31, 2025

Copy link
Copy Markdown
Author

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.

webpatser added a commit to webpatser/fledge-fiber that referenced this pull request Apr 10, 2026
Security:
- Fix HTTP/2 ping flood on active streams (amphp/http-server#386)

Bug fixes:
- Use VarString for string params in binary protocol (amphp/mysql#142)
- Decode BIT columns as int instead of string (amphp/mysql#138)
- Close connections on pool destruct (amphp/http-client#396)
- Fix duplicate keys in byte-stream split() (amphp/byte-stream#113)
- Fix Closure type annotation for static analysis (amphp/amp#451)
- Safely handle DisposedException on unsubscribe (amphp/redis#100)

Features:
- Add TLS support for Redis connections (amphp/redis#98)
- Add disperse() for concurrent closure execution (amphp/amp#460)
@trowski trowski changed the title considering BIT as a Tiny int value Return BIT columns as integer May 1, 2026
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