Bug #68000 Beautify Query Removes Comments
Submitted: 31 Dec 2012 16:45 Modified: 23 Jun 2013 2:00
Reporter: Adam Scott Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:5.2.45 (rev 10251) OS:Any
Assigned to: CPU Architecture:Any

[31 Dec 2012 16:45] Adam Scott
Description:
Beautify Query (CTRL-B) and "Plugins, Utilities>, Reformat SQL" both remove comments in the query.

Beautify Query becomes more useful for larger queries.

Larger queries will tend to have more comments. 

Removing comments makes Beautify Query less useful.

How to repeat:
Place the following query in the editor.

SELECT CONCAT(customer.last_name, ', ', customer.first_name) AS customer,
    address.phone /*customer phone number */, film.title
    FROM rental INNER JOIN customer ON rental.customer_id = customer.customer_id
    INNER JOIN address ON customer.address_id = address.address_id
    INNER JOIN inventory ON rental.inventory_id = inventory.inventory_id
    INNER JOIN film ON inventory.film_id = film.film_id
    WHERE rental.return_date IS NULL #DVD is not returned
    AND rental_date + INTERVAL film.rental_duration DAY < CURRENT_DATE() -- rented before today
     LIMIT 5;

Press CTRL-B

Notice that 
/*customer phone number */
#DVD is not returned
-- rented before today

are removed.

Suggested fix:
Leave comments in Beautify Query.  An alternative is to add another Beautify Query option to leave comments.
[1 Jan 2013 13:13] Valeriy Kravchuk
This is easy to verify on 5.2.44 at least.
[2 Jan 2013 7:48] MySQL Verification Team
Hello Adam,

Thank you for the report.

Verified as described on later GA version.

How to repeat:

Open WB -> SQL Editor and paste below query

SELECT CONCAT(customer.last_name, ', ', customer.first_name) AS customer,
    address.phone /*customer phone number */, film.title
    FROM rental INNER JOIN customer ON rental.customer_id = customer.customer_id
    INNER JOIN address ON customer.address_id = address.address_id
    INNER JOIN inventory ON rental.inventory_id = inventory.inventory_id
    INNER JOIN film ON inventory.film_id = film.film_id
    WHERE rental.return_date IS NULL #DVD is not returned
    AND rental_date + INTERVAL film.rental_duration DAY < CURRENT_DATE() -- rented before today
     LIMIT 5;

// try one of these options to reformat query

Edit->Format->Beautify Query or select query and just Ctrl+B

Also, Plugins->Utilities-> Reformat SQL Query does the similar

Thanks,
Umesh
[27 Feb 2013 6:36] MySQL Verification Team
http://bugs.mysql.com/bug.php?id=68504 marked as duplicate of this one.
[23 Jun 2013 2:00] Alfredo Kojima
Duplicate of bug #65523
[21 Feb 2017 17:24] James Bachelder
Bug 65523, Bug 68000, and Bug 68504 are all duplicates and still not fixed in MySQL Workbench 6.3 Version 6.3.8 build 1228 CE (64 bits) running on Win 10.