Bug #96052 Table Data export wizard failed if data contains Chinese characters in utf8mb4
Submitted: 2 Jul 2019 3:40 Modified: 26 Sep 2019 6:31
Reporter: Xinxin Zhang Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Workbench Severity:S7 (Test Cases)
Version:8.0.16 OS:MacOS (macOS 10.14.x Mojave x86_64)
Assigned to: CPU Architecture:Any
Tags: WBBugReporter

[2 Jul 2019 3:40] Xinxin Zhang
Description:
Table data export/import wizard fails if data contains Chinese character when table default charset is  utf8mb4 and collation is  utf8mb4_unicode_ci . Below is the log message:

=============log message===========
Starting...
Prepare Export...

Traceback (most recent call last):
  File "/Applications/MySQLWorkbench.app/Contents/Resources/libraries/workbench/wizard_progress_page_widget.py", line 71, in run
    self.func()
  File "/Applications/MySQLWorkbench.app/Contents/Resources/plugins/sqlide_power_export_wizard.py", line 248, in prepare_export
    self.module.set_filepath(self.main.select_file_page.output_file)
  File "/Applications/MySQLWorkbench.app/Contents/Resources/plugins/sqlide_power_export_wizard.py", line 380, in output_file
    return str(self.exportfile_path.get_string_value())
UnicodeEncodeError: 'ascii' codec can't encode characters in position 34-35: ordinal not in range(128)
ERROR: Error during Prepare Export: 'ascii' codec can't encode characters in position 34-35: ordinal not in range(128)
ERROR: Exception in task 'Prepare Export': UnicodeEncodeError('ascii', u'/Users/xinxinzhang/Documents/Work/\u6218\u7565/\u8d44\u6599/zhiren_department_staff_count.csv', 34, 36, 'ordinal not in range(128)')

Failed

How to repeat:
1) create a table with default charset = utf8mb4 and  collation =utf8mb4_unicode_ci. Below is my create SQL:

=======create table SQL=======
CREATE TABLE `test_table` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `department_id` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `department_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

2) insert into department_name with some Chinese characters  
3) Try to export data with the Table export wizard. Then you get the error.
4) This happens when  using import wizard as well

Suggested fix:
The data export/import wizard should be abled to export data with Chinese characters in charset utf8mb4_unicode
[26 Sep 2019 6:31] MySQL Verification Team
Hello Xinxin Zhang,

Thank you for the report and test case.
I'm not seeing any issues with dummy data i.e import/export table wizard just works fine with MySQL Workbench Community (GPL) for Mac OS X version 8.0.17 CE build 14960816 (64 bit).
Could you please confirm at your end using WB 8.0.17 and if you are still experiencing this issue then please report us back with same INSERT statements to confirm the issue at our end? Thank you.

If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.  

Thank you for your interest in MySQL.

-- tried with

create database test;
use test;
CREATE TABLE `test_table` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `department_id` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `department_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO test_table VALUES(1,1,'汉字');
INSERT INTO test_table VALUES(2,1,'汉字');
INSERT INTO test_table VALUES(3,1,'汉字');
INSERT INTO test_table VALUES(4,1,'汉字');
INSERT INTO test_table VALUES(5,1,'汉字');

regards,
Umesh