Bug #58569 Format - Beautify Query munges "AS" keyword and alias
Submitted: 29 Nov 2010 20:45 Modified: 6 Jan 2011 14:58
Reporter: Steven Maggs Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:5.2.30 OS:Any
Assigned to: Alfredo Kojima CPU Architecture:Any

[29 Nov 2010 20:45] Steven Maggs
Description:
The Beautify Query function does not recognize the optional "AS" keyword in table references.  When using "AS" with a table alias, the beautify function concatenates the "AS" keyword and alias, which causes any references to the original alias to fail.

How to repeat:
1. Enter a query that uses the "AS" keyword in the editor window, such as

  SELECT a.* from sometable as a

2. From the Edit menu, select Format -> Beautify Query

3. The query will be changed to:

SELECT 
        a.*
    from
        sometable asa

Suggested fix:
Correct output is

SELECT 
        a.*
    from
        sometable as a
[29 Nov 2010 23:03] Alfredo Kojima
fixed in repository
[8 Dec 2010 20:25] Johannes Taxacher
fix confirmed in repository
[6 Jan 2011 14:58] Tony Bedford
An entry has been added to the 5.2.31 changelog:

The Beautify Query facility in the SQL Editor did not recognize the optional AS keyword in table references. When AS was used with a table alias, the beautify function concatenated the AS keyword and alias, which caused any references to the original alias to fail.