Bug #51308 MySQL Workbench Query Editor doesn't use OS appropriate file format
Submitted: 19 Feb 2010 8:38 Modified: 20 May 2010 10:35
Reporter: Terry Bailey Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S2 (Serious)
Version:5.2.16 rev 5249 OS:Windows (Windows 7)
Assigned to: Sergei Tkachenko CPU Architecture:Any
Tags: SQL Editor Query EOL crlf new line

[19 Feb 2010 8:38] Terry Bailey
Description:
When opening a SQL file created with previous tools like MySQL Query Browser or any other text editor in Windows the files are not always recognized correctly.  An extra line break is visible between each line most likely because the editor is using a unix style new line marker instead of the windows appropriate carriage return / line feed combination.  This makes the file incompatible with any other text editor in the OS.  

The same is true when saving a newly created file and opening it in another text editor.

In some cases completely valid SQL syntax is somehow misinterpreted as well.
The "select" in 

select *
from temp

was marked as incorrect syntax until deleted and re-typed.  This can and will cause a large barrier to moving to this tool for anyone with significant numbers of stored procedures or other scripts already created with other tools.

How to repeat:
1) Open an sql script created with MySQL Query Browser or created in Notepad in the MySQL Workbench Editor on the Windows platform.

Extra blank lines will be present between each line of script.  And in some cases perfectly valid SQL syntax will be seen as invalid.

2) Create a new SQL script in MySQL Workbench Editor and save it to disk.

Open this file in notepad or any other windows text editor and lines will run together that were separated by carriage returns in the editor.  

Suggested fix:
Use OS appropriate file formats for writing files to disk and reading them from disk.
[19 Feb 2010 9:56] Valeriy Kravchuk
Thank you for the bug report. Verified just as described on Windows XP. Looks like SQL Editor uses/expects UNIX-style 0x0D line endings in scripts instead of DOS/Windows 0x0A 0x0D.
[13 Apr 2010 23:23] Alfredo Kojima
SQL Editor should detect line ending and convert them on load in Windows.
When saving, crlf should be used in windows.
[14 May 2010 10:55] Sergei Tkachenko
SQL Editor was enhanced to support custom EOL formats and now preserves original line endings used in the file. Platform default EOL format is used for new files.
In case of line endings inconsistency in the file, WB suggests user to select EOL format to apply, which aligns all EOLs to the specified format.
[18 May 2010 18:01] Johannes Taxacher
fix confirmed in repository
[20 May 2010 10:35] Tony Bedford
An entry has been added to the 5.2.22 changelog:

If a SQL file, using Windows file format, was loaded into the SQL Editor, it was displayed with additional line breaks, and the SQL code was not interpreted correctly. Further, if code written in the SQL editor was saved to a file and then opened in an editor on Windows, it contained additional line breaks.
[23 May 2010 13:07] Alfredo Kojima
Bug #53868 marked as duplicate