Bug #99585 SQL statement is built incorrectly when bit fields are present
Submitted: 15 May 2020 11:05 Modified: 15 May 2020 12:11
Reporter: Tad Adams Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:8.0.20, 8.0.24, 8.0.25 OS:Windows (Microsoft Windows 10 Enterprise)
Assigned to: CPU Architecture:x86
Tags: WBBugReporter

[15 May 2020 11:05] Tad Adams
Description:
When I add rows to a table that contains bit fields then click apply, the sql statement correctly places a "b" before the bit value: b'0' and b'1', however, it then proceeds to prefix a "b" to every value thereafter no matter what field type: varchar - b'dog', int - b'355'.  This causes the sql statement to fail unless I manually remove the erroneous "b".

How to repeat:
Create a table
Add a bit field
Add a non bit field
Save the table schema
Right-click on the table name and select "Select Rows"
Add a new row with valid field data, 0 or 1 for the bit field and data in the non bit field.
Click Apply
Examine the SQL statement and check the value for the non bit field.  It will be prefixed with a "b".

This is the table definition I am using:

CREATE TABLE `PlayerSpells` (
  `CharacterName` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `SpellID` int(1) NOT NULL,
  `Acquired` bit(1) NOT NULL DEFAULT b'0',
  `Source` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`CharacterName`,`SpellID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

SQL statement after adding 2 rows and clicking Apply:

INSERT INTO `ffxi`.`PlayerSpells` (`CharacterName`, `SpellID`, `Acquired`, `Source`) VALUES ('Burghalarmada', '355', b'0', b'Lunar Eclipse');
INSERT INTO `ffxi`.`PlayerSpells` (`CharacterName`, `SpellID`, `Acquired`, `Source`) VALUES (b'Burghallocal', b'355', b'0', b'Lunar Eclipse');

The first 3 fields in the first row are correct, but after the first bit field it seems to get stuck prefixing 'b' to all remaining field values, even into the next row.

Suggested fix:
Check if the field type is bit before prefixing 'b' to the field value.
[15 May 2020 12:11] MySQL Verification Team
Hello Tad Adams,

Thank you for the report and feedback.

regards,
Umesh
[15 Sep 2020 22:01] MySQL Verification Team
https://bugs.mysql.com/bug.php?id=99195 marked as duplicate of this one.
[13 May 2021 5:37] MySQL Verification Team
Bug #103674 marked as duplicate of this one
[13 May 2021 13:17] MySQL Verification Team
Bug #103673 marked as duplicate of this one