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: Won't Fix 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
[19 Feb 22:33] David Flor
This bug has existed for SIX YEARS?!? Its the most annoying thing ever, makes it almost impossible to edit through the workbench UI when you get these update queries that are all formatted wrong,
[14 Sep 18:05] Omer Barnir
Posted by developer:

This issue applies to the legacy MySQL Workbench 8.x implementation that is no longer supported or maintained.
MySQL Workbench 26.7 is a complete rewrite using a new technology stack and does not use the affected legacy implementation.
Therefore, this issue is not applicable to the current MySQL Workbench product and as such is closed.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.052 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.