Questions about visualizing SQL code in a query

My question may seem trivial or unimportant to some, but it still leaves me perplexed.
.
I noticed when viewing certain requests from people who helped me solve problems I had with my DB that the code used in their requests appeared in this form:
.

select "Role", "RoleID"
from "TROLES"
order by 1

.
When I create a new query and write this code the same way, LibreOffice saves it like this:
.


SELECT “Role”, “RoleID” FROM “TROles” ORDER BY 1

.
The first way is more readable and understandable for me. Why doesn’t LibreOffice take this into account at all? Is there a way to ensure that when we save the request the format is preserved?

1 Like

I guess you’re talking about bug 86315 – EDITING: Formatting of queries should be saved by base.

Of course something like

would be more readable but a single line.

I think if you turn on direct sql it saves the format. But apparently it introduces other problems as well.


EDIT: You could add yourself to the cc list in the bug report above. It might help to increase the priority of that bug. I read, though, that libreoffice base is lacking maintainers / programmers and doesn’t receive much updates currently.

1 Like

Ok thanks @TheSmallest,
.
I understand. However, this does not affect the proper functioning of the query; it’s just that we lose the readability or the format and the writing conventions of the language after saving the query., everything is rewritten on a single line and it’s not easy to navigate when queries are long and complex.
.
This may be a problem only related to LibreOffice Base’s built-in HSQLDB engine. There may not be this problem if we use another engine like PostgreSQL. I don’t know…
.
In any case, I will make a habit of keeping a copy of the query format in a text file and will refer to it as needed.
.
Nothing is perfect!

1 Like

I know - you have this reformatting with any database unless you set the checkmark for “direct sql”.

Try appending a comment /* … */ and copy the query in the comment. The comment should retain the formatting.
.
Another option would be to use an external pretty-print for SQL before posting your code.

1 Like