Skip to content

fix(mysql): display BIT field values as decimal instead of hex bytes#1273

Merged
datlechin merged 2 commits into
TableProApp:mainfrom
shouwang0527:fix/bit-type-field-display
May 15, 2026
Merged

fix(mysql): display BIT field values as decimal instead of hex bytes#1273
datlechin merged 2 commits into
TableProApp:mainfrom
shouwang0527:fix/bit-type-field-display

Conversation

@shouwang0527
Copy link
Copy Markdown
Contributor

Summary

MySQL bit(1) fields were incorrectly treated as binary data, causing values like 0x01 to display as ^A (control character).

Root Cause

  • MariaDBFieldClassifier.isBinary() returned true for MYSQL_TYPE_BIT (type code 16), treating bit fields as binary blobs
  • Binary values were passed through BlobFormattingService and displayed as hex, showing control characters

Fix

  • Remove MYSQL_TYPE_BIT from binary classification in MariaDBFieldClassifier
  • Add isBit() detection and bitFieldToString() to convert packed binary representation to decimal string
  • Propagate columnIsBit through all three query execution paths (sync, prepared statements, streaming)

Result

del_flag values now display as 0/1 instead of ^A/^@

Fixes #1272

MySQL bit(1) fields were incorrectly treated as binary data, causing
values like 0x01 to display as "^A" (control character). This change:

- Removes MYSQL_TYPE_BIT (16) from the binary classification logic
  in MariaDBFieldClassifier.isBinary(), since BIT is not truly binary
- Adds MariaDBFieldClassifier.isBit() to detect BIT type fields
- Adds bitFieldToString() to convert the packed binary representation
  (MSB-first) into a human-readable decimal string
- Propagates columnIsBit through all three query execution paths
  (sync, prepared statements, streaming)

Fixes TableProApp#1272
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@shouwang0527
Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA.

github-actions Bot added a commit that referenced this pull request May 15, 2026
- Move bitFieldToString into MariaDBFieldClassifier so the BIT decode helper lives with the BIT detector.
- Drop the columnIsBit: [Bool] parallel array threaded through MariaDBPluginQueryResult, the three query paths, and fetchResultSet. The type code in columnTypes[i] is sufficient and MariaDBFieldClassifier.isBit(typeRaw:) is O(1).
- Fix MariaDBFieldClassifierTests.bitIsBinary which asserted the old (broken) behavior. Replace with bitIsNotBinary and add coverage for isBit and bitFieldToString across 1-byte, multi-byte, BIT(64) max, empty buffer, and the Data overload.
- Add CHANGELOG entry under [Unreleased] > Fixed.
Copy link
Copy Markdown
Member

@datlechin datlechin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@datlechin datlechin merged commit 8edd329 into TableProApp:main May 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mysql中 bit(1)类型字段,无法正常显示字段的值

2 participants