sql-formatter-org / sql-formatter

A whitespace formatter for different query languages
https://sql-formatter-org.github.io/sql-formatter/
MIT License
2.32k stars 398 forks source link

Feature Request: Option to Configure Indentation for SQL JOIN Clauses #716

Open ko-ya346 opened 7 months ago

ko-ya346 commented 7 months ago

I would like to propose a feature that allows users to configure the indentation for SQL JOIN clauses through an option. This feature would enable more flexibility in formatting SQL queries to match different coding styles and preferences.

Specifically, I'm looking for the ability to format JOIN clauses like the following example:

SELECT
    logs.*,
    master.status
FROM
    logs
LEFT OUTER JOIN
    master
ON
    logs.id = master.id

This formatting style increases readability by clearly separating each part of the JOIN clause with consistent indentation. It would be great to have an option in the SQL Formatter that allows us to achieve this level of clarity in our SQL code.

Thank you for considering this feature request.

nene commented 7 months ago

Thanks for the suggestion.

The indentation of the FROM-clause has probably the most variations in the already pretty tricky world of SQL code indentation.

It's hard to please everyone. I would need to add several configuration options to cover all the possible styles.

Also, I'm not really doing active feature development on SQL Formatter any more. Instead concentrating on prettier-plugin-sql-cst. But that one also doesn't indent the FROM clause the way you would like and the goal of it is really to be pretty opinionated in its formatting style.

ko-ya346 commented 7 months ago

Thank you for your reply. I understand that my proposal may not be easily implemented. I will consider what additional settings might make these variations possible.

I was not aware of prettier-plugin-sql-cst. Thank you for the information. I plan to try it out and see what it can do.