-
Notifications
You must be signed in to change notification settings - Fork 0
Formatting of SQL Function Parameters with Keyword Elements #409
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
Merged
xterao
merged 5 commits into
fix/sql-formatter
from
fix/sql-formatter-incorrect-formatting-function-in-condition-directive
Aug 22, 2025
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6fc5fe2
Move SqlCommaBlock
xterao 624d806
Enhance SQL formatting by refining indentation logic and preventing u…
xterao 1aa62ee
Add tests and formatting for function keyword in condition directive
xterao 10ea283
Remove commented-out code and simplify child text length calculation …
xterao 638527b
Remove duplicate SqlFunctionParamBlock from block class list in SqlCo…
xterao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
21 changes: 21 additions & 0 deletions
21
src/test/testData/sql/formatter/FunctionKeywordInConditionDirective.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| -- PostgreSQL | ||
| SELECT extract(YEAR FROM e.hire_date) AS hire_year FROM employees e | ||
| SELECT extract(MONTH FROM e.hire_date) AS hire_month FROM employees e | ||
| -- Oracle | ||
| SELECT TO_DATE('2024-01-01', 'YYYY-MM-DD') AS new_year FROM dual | ||
| SELECT TO_CHAR(e.hire_date, 'YYYY-MM') AS hire_month FROM employees e | ||
| SELECT CURRENT_DATE FROM dual | ||
| --MySQL | ||
| SELECT YEAR(e.hire_date) AS hire_year FROM employees e | ||
| SELECT MONTH(e.hire_date) AS hire_month FROM employees e | ||
| SELECT DATE_FORMAT(e.hire_date, '%Y-%m') AS hire_month FROM employees e | ||
| -- SQL Server | ||
| SELECT DATEPART(YEAR, e.hire_date) AS hire_year FROM employees e | ||
| SELECT DATEPART(MONTH, e.hire_date) AS hire_month FROM employees e | ||
| SELECT CONVERT(VARCHAR, e.hire_date, 23) FROM employees e | ||
| -- SQLite | ||
| SELECT strftime('%Y', e.hire_date) AS hire_year FROM employees e | ||
| SELECT strftime('%m', e.hire_date) AS hire_month FROM employees e | ||
| -- Standard SQL | ||
| SELECT CURRENT_TIMESTAMP FROM employees | ||
| SELECT CAST(e.salary AS INTEGER) FROM employees e |
45 changes: 45 additions & 0 deletions
45
src/test/testData/sql/formatter/FunctionKeywordInConditionDirective_format.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| -- PostgreSQL | ||
| SELECT extract(YEAR FROM e.hire_date) AS hire_year | ||
| FROM employees e | ||
| SELECT extract(MONTH FROM e.hire_date) AS hire_month | ||
| FROM employees e | ||
| -- Oracle | ||
| SELECT TO_DATE('2024-01-01' | ||
| , 'YYYY-MM-DD') AS new_year | ||
| FROM dual | ||
| SELECT TO_CHAR(e.hire_date | ||
| , 'YYYY-MM') AS hire_month | ||
| FROM employees e | ||
| SELECT CURRENT_DATE | ||
| FROM dual | ||
| --MySQL | ||
| SELECT YEAR(e.hire_date) AS hire_year | ||
| FROM employees e | ||
| SELECT MONTH(e.hire_date) AS hire_month | ||
| FROM employees e | ||
| SELECT DATE_FORMAT(e.hire_date | ||
| , '%Y-%m') AS hire_month | ||
| FROM employees e | ||
| -- SQL Server | ||
| SELECT DATEPART(YEAR | ||
| , e.hire_date) AS hire_year | ||
| FROM employees e | ||
| SELECT DATEPART(MONTH | ||
| , e.hire_date) AS hire_month | ||
| FROM employees e | ||
| SELECT CONVERT(VARCHAR | ||
| , e.hire_date | ||
| , 23) | ||
| FROM employees e | ||
| -- SQLite | ||
| SELECT strftime('%Y' | ||
| , e.hire_date) AS hire_year | ||
| FROM employees e | ||
| SELECT strftime('%m' | ||
| , e.hire_date) AS hire_month | ||
| FROM employees e | ||
| -- Standard SQL | ||
| SELECT CURRENT_TIMESTAMP | ||
| FROM employees | ||
| SELECT CAST(e.salary AS INTEGER) | ||
| FROM employees e |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.