Bug #75974 Using the beautify feature changes the REGEX string
Submitted: 20 Feb 2015 7:26 Modified: 20 Feb 2015 8:00
Reporter: Database Administrator Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:6.2.4.12437, 6.2.5 OS:Linux
Assigned to: CPU Architecture:Any
Tags: beautify, editor, editor, regex, workbench

[20 Feb 2015 7:26] Database Administrator
Description:
When making use of the beautify feature/function it changes the context of the REGEX in certain cases.

The changes to the REGEX impacts on the results obtained from the query.

How to repeat:
1.) Write query in the SQL editor.
SELECT 
    id, 
    pdflocation
FROM
    my_db.some_table
WHERE
    pdflocation NOT REGEXP '\\[(\\"[12][019][0-9]{2}\\\\/(jan|jul)\\\\/gg[0-9]{5}\_nn[0-9]{1,4}[a-z]{0,1}\.pdf\\"[,]{0,1})*\\]'

2.) use the beautify function (ctrl+b)
3.) the content and context of the REGEXP changes to:
SELECT 
    id, pdflocation
FROM
    my_db.some_table
WHERE
    pdflocation NOT REGEXP '\[(\"[12][019][0-9]{2}\\/(jan|jul)\\/gg[0-9]{5}\_nn[0-9]{1,4}[a-z]{0,1}.pdf\"[,]{0,1})*\]'

4.) In short:
changes REGEXP 
FROM
'\\[(\\"[12][019][0-9]{2}\\\\/(jan|jul)\\\\/gg[0-9]{5}\_nn[0-9]{1,4}[a-z]{0,1}\.pdf\\"[,]{0,1})*\\]'
TO
'\[(\"[12][019][0-9]{2}\\/(jan|jul)\\/gg[0-9]{5}\_nn[0-9]{1,4}[a-z]{0,1}.pdf\"[,]{0,1})*\]'
[20 Feb 2015 8:00] MySQL Verification Team
Hello!

Thank you for the report.
Observed this on Win7 with WB 6.2.5.

Thanks,
Umesh
[20 Feb 2015 10:43] Peter Laursen
This is enough testcase:

SELECT 'a' REGEXP '\\a'
>> becomes >>
SELECT 'a' REGEXP '\a'

-- peter
-- not a MySQL/Oracle prson
[20 Feb 2015 11:29] Peter Laursen
The problem is not with REGEXP. It is basically mis-treatment of strings by the 'beautifier'. This is probably simplest testcase:

SELECT '\\a'
>> becomes >>
SELECT '\a'

Listerals inside a 'quoted string' (or "quoted string") the 'beautifier' should not be touched at all.
[26 Jul 2015 10:18] Paul Weiss
Still occurring for me on 6.3.4.0 on Microsoft Windows 7 Home Premium SP 1, 64-bit.
[30 Aug 2016 20:49] Tanner Means
Platform: linux (Ubuntu 14.04)

This also affects hex literals:

select 0x1234

will be truncated to 

select 0x12

Each time beautify is used, another 2 characters are taken off all hex literals
[30 Aug 2016 20:50] Tanner Means
Whoops I figure it'll be helpful to have my workbench build info as well:
Version 6.0.8.11354 build 833