Skip to content

Remove multi-lines queries.#28

Open
jfg956 wants to merge 1 commit intosjmudd:masterfrom
jfg956:no_multi-line_queries
Open

Remove multi-lines queries.#28
jfg956 wants to merge 1 commit intosjmudd:masterfrom
jfg956:no_multi-line_queries

Conversation

@jfg956
Copy link
Copy Markdown

@jfg956 jfg956 commented Jan 13, 2026

In the code, some queries are single line (example below)...

..and some others are multi-line (example below).

The multi-line queries generate harder to parse general logs, and IMHO are sub-optimal.

This PR removes all the multi-line queries I found (I might have missed some).

(I also simplified a query removing AS, from what I saw, they were not eneded)

@jfg956 jfg956 marked this pull request as ready for review January 13, 2026 23:03
@ericherman
Copy link
Copy Markdown
Contributor

The multi-line queries are harder to parse in logs, but far more readable in source.

Perhaps there is a \ approach which would serve the machine log parsing goal and also the human code reading goal.

@jfg956
Copy link
Copy Markdown
Author

jfg956 commented Jan 14, 2026

Hello Eric,

The multi-line queries are harder to parse in logs, but far more readable in source.

Right, I understand source readability, but as I pointed-out in the PR description, some other queries are single-line in the code, and not super readable. My PR is not "breaking everything", just making things consistent.

serve the machine log parsing goal

The goal is not as much "machine log parsing" as general elegance. A good general log parser will have to deal with multi-line queries sooner or later as devs are likely to like them. IMHO, dba tooling should aim at minimizing dba pains, hence my current suggestion.

I could come-up with a solution which would take a multi-line query in code, pass it through paste -s -d " ", and then `sed -e 's/ */ /g;s/^ *//;s/ *$//' (obviously all in go), but it was more simple to me to make consistent with existing (in the direction I wanted), than fix / break everywhere. If it is decided that fixing everywhere is the way forward, I might submit a new PR.

Cheers, J-F

@ericherman
Copy link
Copy Markdown
Contributor

Certainly things are not consistent. If consistency is the goal, I'd favour making things consistent for human readability, but this would be a style choice, not a technical choice.

Perhaps something like this would be easy to parse by machines and also easy to read by devs:

query := "SELECT foo " +
         "  FROM bar " +
         " WHERE baz = ?;"

@jfg956
Copy link
Copy Markdown
Author

jfg956 commented Jan 14, 2026

Perhaps something like this would be easy to parse by machines and also easy to read by devs [...].

I would down-vote this suggestion. It makes it impossible to cut-and paste the query for testing in a shell. So IMHO, this new style suggestion is worse than the two styles already present in the code.

@ericherman
Copy link
Copy Markdown
Contributor

ericherman commented Jan 14, 2026

Then yes, your earlier suggestion of a processing step (suggested as a sed command, but could as you say be in the code), seems more attractive to me. Your mileage may vary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants