Repository navigation
Add --join-on-indent option to indent multi-keyword join ON clauses - #407
Merged
Merged
Conversation
Add a new option --join-on-indent that indents the ON clause
continuation lines (AND/OR) of a multi-keyword join (e.g. LEFT OUTER
JOIN) one level below the join keyword.
By default the option is off and the existing behavior is preserved.
Without the option (default):
LEFT OUTER JOIN ab_frap appel ON appel.frap_tyap_code = tyap.tyap_code
AND appel.frap_imme_no = tyap.tyap_imme_no
With --join-on-indent:
LEFT OUTER JOIN ab_frap appel ON appel.frap_tyap_code = tyap.tyap_code
AND appel.frap_imme_no = tyap.tyap_imme_no
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add a new option
--join-on-indentthat indents theONclause continuation lines (AND/OR) of a multi-keyword join (e.g.LEFT OUTER JOIN) one level below the join keyword.The option is off by default — the existing behavior is fully preserved.
Without the option (default, unchanged)
With
--join-on-indentWhy
When a join is spelled with several keywords (
LEFT OUTER JOIN,FULL JOIN, …), pgFormatter steps the indentation back once per keyword, so theONclause continuation lines end up at the same level as the join keyword. Some style guides prefer theAND/ORcontinuation lines to be indented one level below the join keyword. This option provides that style without changing the default output.Implementation
lib/pgFormatter/Beautify.pm: newjoin_on_indentoption (POD,qw()list,set_defaults), and the join step-back condition now only skips the per-keyword step-back when the option is on.lib/pgFormatter/CLI.pm:--join-on-indentCLI flag, config mapping, and help text.t/test-files/ex85.sql+t/test-files/expected/ex85.sql: regression test coveringLEFT OUTER JOIN,INNER/CROSS/NATURAL/RIGHT/FULL JOIN, and plainJOIN/LEFT JOIN, run with--join-on-indent.Tests
prove -lv t/passes (93 tests). The existingex1.sql(which contains aLEFT OUTER JOIN … ON … AND …) still passes because the default behavior is unchanged.