Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ko-ya346 opened this issue Feb 9, 2024 · 2 comments
Open
Labels

Comments

@ko-ya346
Copy link

ko-ya346 commented Feb 9, 2024

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
Copy link
Collaborator

nene commented Feb 9, 2024

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.

  • is each join indented to the same level as FROM or one level deeper?
  • is the ON placed on a separate line?
  • is ON indented the same amount as the join or deeper?
  • do you indent the name of the joined table?
  • do you indent the condition after ON?

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants