SQL query formatting not preserved when saving query

LO_7.0.2.2, HSQLDB embedded & Registered, Windows10_64bit

Is it possible to preserve “formatting” of queries in SQL view?

Details:

  • When creating complex queries it can be helpful to visually “edit” them a bit, to better follow their logical structure.
  • By adding [Tabs] , [Carriage Returns] , /* Comments */ to the SQL, some complex queries can look a bit easier read &/or understand.
  • Then, after saving, closing, and re-opening the query, the [Tab]-formatting and [CR]-formatting is gone (looks like /* Comments */ are pushed towards the end), and the SQL is displayed as a “flat” long in-line string, which is more difficult to decipher than the “edited” SQL.

For Example:

  • In the LO_Main_Window, click [Queries], then click [Create Query in SQL View …]
  • Then enter the SQL query and “edit” it by adding [Tabs] , [Carriage Returns] , /* Comments */, to make it more legible.


SELECT “Recorded Time”, “Sampled Time”, “Pressure”, “Temperature”
FROM “DOE-004” WHERE “Recorded Time” =
( SELECT MAX( “Recorded Time” ) FROM “DOE-004” WHERE “Pressure” = /* get corr timestamp /
( SELECT MAX( “Pressure” ) FROM /
get max pressure /
( SELECT “Pressure” FROM “DOE-004” WHERE “Pressure” < ‘A’ ) /
ignore chars */
)
)

  • Then, saving & closing the query.
  • Then re-opening the query via right-click on the query, [edit in SQL View]

Now the SQL query looks “flat” with all comments moved to its end.


SELECT “Recorded Time”, “Sampled Time”, “Pressure”, “Temperature” FROM “DOE-004” WHERE “Recorded Time” = ( SELECT MAX( “Recorded Time” ) FROM “DOE-004” WHERE “Pressure” = ( SELECT MAX( “Pressure” ) FROM ( SELECT “Pressure” FROM “DOE-004” WHERE “Pressure” < ‘A’ ) ) ) /* get corr timestamp // get max pressure // ignore chars */

So, is there a way in LO to preserve the “SQL-string-formatting”, so when re-opening the query next time, one can see the “easier-to-read” version of the query?

Please see tdf#86315

Only way to currently preserve is to turn on Run SQL command directly. This can negatively affect the operation of the SQL in some cases.