Description:
Reformatting SQL code in the SQL Editor causes commented lines to be deleted. This is a WTF behavior.
How to repeat:
1. Insert a block of valid SQL statements in the editor
2. Invoke the Reformat SQL Query function via any of the available mechanisms (Edit menu, toolbar button, Utilities menu)
3. Comment out some lines with any of the comment characters (--, #, /* */)
4. Reformat the query again
5. The commented lines are deleted
Suggested fix:
Inline comments in SQL code are valuable for documentation, versioning, ease of maintenance, and are often used as a mechanism to easily enable and disable individual subexpressions in a larger block of common code -- for instance, for debugging purposes, or to avoid having to maintain two separate code files when a single complex query can serve two purposes by commenting or uncommenting an expression or two.
Deleting commented lines during SQL code reformatting punishes developers who use comments to make their code more understandable. Shame on you!
The appropriate behavior for handling comments in a code reformatter is to either reindent the comment to the left margin, or reindent to the current block indent, or don't move it at all. But don't reformat or parse any code within the commented line (keywords, expressions, objects, etc.).
These behaviors can (and should) be controlled via checkbox or radiobutton options in the Preferences panel in the SQL tab:
[ ] Retain inline comments in SQL code
( ) Comments always start at left margin
(o) Comments start at current block indent
( ) Comments retain relative position (no reindenting)
The last radiobutton option is for comments that appear at the end of a line of code. The user probably doesn't want them to be displaced from the line of code they're associated with.