Bug #100816 Script beautifier replacing \r\n with actual newline.
Submitted: 11 Sep 2020 13:36 Modified: 11 Sep 2020 16:18
Reporter: Kevin Finkenbinder Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:8.0.21 OS:Any
Assigned to: MySQL Verification Team CPU Architecture:Any

[11 Sep 2020 13:36] Kevin Finkenbinder
Description:
When reformatting/beautifying a sql script that includes \n or \r, the beautifier turns it into an actual newline character instead of preserving the text.  (e.g.  '\r\n' turns into '
').  This breaks code that needs to compare with the literal characters.

How to repeat:
1) create a new query that includes \r or \n.
 (e.g. select * from data where data.node like '%\r\n%';).  
2) execute the code beautifier/reformatter.
3) (query now reads select * from data where data.node like '%
%';)

Suggested fix:
d
[11 Sep 2020 13:38] Kevin Finkenbinder
Query before running code beautifier (note \r\n in where clause.

Attachment: Query before beautifier.png (image/png, text), 36.19 KiB.

[11 Sep 2020 13:38] Kevin Finkenbinder
Query AFTER running code beautifier (note actual newline in where clause).

Attachment: Query after beautifier.png (image/png, text), 30.92 KiB.

[11 Sep 2020 13:50] Kevin Finkenbinder
I should note, this also messes up comparisons because not only does it put in a newline character instead of \r\n, it also puts spaces/indents into the middle of the search string.  Things inside quotes should be sacrosanct and not modified by the beautifier.
[11 Sep 2020 16:18] MySQL Verification Team
Thank you for the bug report.