Bug #103329 Workbench: Synchronize with Any Source. Wrong results with JSON columns
Submitted: 15 Apr 2021 10:21 Modified: 16 Apr 2021 12:24
Reporter: Enrico Montagna Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Workbench Severity:S2 (Serious)
Version:8.0.23 OS:Windows (Microsoft Windows 10 Pro)
Assigned to: CPU Architecture:Any
Tags: WBBugReporter

[15 Apr 2021 10:21] Enrico Montagna
Description:
The results of "Synchronize with Any Source" will present wrong results when the table contains a JSON field and the source and/or destination is a script file .sql

Two scenario are presented.
Scenario 1. When the source is the "Model Schemata" and the destination is a script file, the synchronization result is a "create table" instead the alter query

Scenario 2. When the source is the a script file and the destination is either a script file, the synchronization result is a empty instead the alter query

It has been verified in 
- Windows 10 64bit, Workbench version 8.0.23
- Oracle Linux 7 64bit, Workbenc version 8.0.22

How to repeat:
Scenario 1.
- File > New Model
- File > Import > Reverse Engineer SQL Script. Select "schema1.sql" file and place objects on diagram
- Amend something on the table in the diagram e.g. change the "name" field from VARCHAR(100) to VARCHAR(150)
- Database > Synchronize with Any Source
- Select "Model Schemata" as source and original "schema1.sql" script file as destination
The result of the next steps is the whole "CREATE TABLE..." statement.
The expected result is the "ALTER" statement of the changed field VARCHAR type

Scenario 2.
- File > New Model
- Database > Synchronize with Any Source
- Select "schema1.sql" script file as source and "schema1.sql" script file as destination (the 2 files differences only for the name of a varchar field, both have a JSON field)
The result of the next steps is empty.
The expected result is the right statement to change the field name

-- --------- TEST CASE SQL -----------

-- schema1.sql

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

-- ----------------------------------------------------------------------------
-- Schema main
-- ----------------------------------------------------------------------------
DROP SCHEMA IF EXISTS `main` ;
CREATE SCHEMA IF NOT EXISTS `main` DEFAULT CHARACTER SET utf8 ;

-- ----------------------------------------------------------------------------
-- Table main.dummytest
-- ----------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `main`.`dummytest` (
  `id` INT(10) NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(100) NULL DEFAULT NULL,
  `test` JSON NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `name_UNIQUE` (`name` ASC))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

-- --------- TEST CASE SQL -----------

-- schema2.sql
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

-- ----------------------------------------------------------------------------
-- Schema main
-- ----------------------------------------------------------------------------
DROP SCHEMA IF EXISTS `main` ;
CREATE SCHEMA IF NOT EXISTS `main` DEFAULT CHARACTER SET utf8 ;

-- ----------------------------------------------------------------------------
-- Table main.dummytest
-- ----------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `main`.`dummytest` (
  `id` INT(10) NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(100) NULL DEFAULT NULL,
  `test2` JSON NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `name_UNIQUE` (`name` ASC))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
[15 Apr 2021 10:22] Enrico Montagna
Schema1.sql test case file

Attachment: schema1.sql (application/octet-stream, text), 1.05 KiB.

[15 Apr 2021 10:22] Enrico Montagna
Schema2.sql test case file

Attachment: schema2.sql (application/octet-stream, text), 1.05 KiB.

[15 Apr 2021 10:24] Enrico Montagna
WB Log file

Attachment: wb.log (application/octet-stream, text), 6.28 KiB.

[15 Apr 2021 10:24] Enrico Montagna
Scenario1. steps to reproduce

Attachment: scenario1_wrong_synch_schemata.mp4 (video/mp4, text), 2.56 MiB.

[15 Apr 2021 10:25] Enrico Montagna
Scenario2. steps to reproduce

Attachment: scenario2_empty_synch_script_file.mp4 (video/mp4, text), 2.79 MiB.

[16 Apr 2021 12:24] MySQL Verification Team
Hello Enrico Montagna,

Thank you for the bug report.
Verified as described.

Regards,
Ashwini Patil