-
Notifications
You must be signed in to change notification settings - Fork 0
Fix SQL formatter issues with ORDER BY/GROUP BY clauses and improve block indentation handling #431
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
Conversation
…djustments for function parameter blocks
…ormatted correctly.
…ing function block has no argument parameters
… level should be combined into a single line
… conditional loop directives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes SQL formatting issues with ORDER BY and GROUP BY clauses, particularly when used with Doma condition directives and within function parameters. The changes improve block indentation handling and ensure proper alignment of SQL keywords within conditional blocks.
- Improved ORDER BY/GROUP BY formatting with condition directives by fixing indentation and spacing
- Enhanced block indentation logic for nested conditional blocks and function parameters
- Added comprehensive test coverage for the formatting improvements
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| SqlKeywordUtil.kt | Added new keywords and improved keyword relationship mappings |
| SqlBlockGenerator.kt | Enhanced function name detection and table block handling |
| SqlFormatPreProcessor.kt | Fixed keyword formatting after block comments |
| NotQueryGroupHandler.kt | Added parameter keyword detection for better block creation |
| SqlBlockRelationBuilder.kt | Refactored parent group assignment logic and improved indentation calculation |
| SqlFunctionGroupBlock.kt | Fixed function block indentation calculation |
| SqlSubQueryGroupBlock.kt | Improved child block filtering for indentation |
| SqlSubGroupBlock.kt | Enhanced new line detection for conditional blocks |
| SqlSecondKeywordBlock.kt | Improved space handling for function parameters |
| SqlKeywordGroupBlock.kt | Enhanced space handling with condition directives |
| SqlElConditionLoopCommentBlock.kt | Fixed line break detection logic |
| SqlCommaBlock.kt | Improved indentation and spacing for function parameters |
| SqlRightPatternBlock.kt | Added comments for parenthesis handling |
| SqlFileBlock.kt | Enhanced spacing logic for function parameters and operation symbols |
| SqlBlock.kt | Improved text length calculation and added operation symbol detection |
| TypeUtil.kt | Added SqlColumnRawGroupBlock to expected types |
| Test files | Added comprehensive test cases for ORDER BY/GROUP BY formatting |
| Token files | Added missing SQL keywords and function tokens |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/main/kotlin/org/domaframework/doma/intellij/formatter/util/SqlKeywordUtil.kt
Show resolved
Hide resolved
src/main/kotlin/org/domaframework/doma/intellij/formatter/block/word/SqlFunctionGroupBlock.kt
Show resolved
Hide resolved
src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlBlock.kt
Show resolved
Hide resolved
a3d8719 to
c37d509
Compare
Description
This PR addresses issue #428 by fixing multiple SQL formatting issues related to ORDER BY and GROUP BY clauses, particularly when used with Doma condition directives and within function parameters.
Changes Made
1. Improved ORDER BY formatting with condition directives
/*%if*/condition directives2. Fixed GROUP BY formatting issues
3. Enhanced block indentation logic
4. Added comprehensive test coverage
Example of Fixed Formatting
Before:
After:
Testing
All existing tests pass, and new test cases have been added to ensure the formatting improvements work correctly with:
Related Issues
Fixes #428
Checklist