-
Notifications
You must be signed in to change notification settings - Fork 0
Fix SQL formatting for multiple CASE expressions support #357
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
Fix SQL formatting for multiple CASE expressions support #357
Conversation
…hips to a builder class.
… parenthesis when the block is an `SqlInsertValueGroupBlock` block class.
…ntBlock', excluding comments
…hips to a builder class.
…ditionLoopCommentBlock` and determine whether the block should be line-broken.
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 enhances SQL formatting behavior to improve support for multiple CASE expressions and overall SQL formatting consistency. The changes focus on upgrading the formatter's handling of spacing, line-breaking, indentation, and block relationships.
- Improved SQL formatting for multiple CASE expressions and various SQL directive patterns
- Enhanced block relationship management using a builder pattern
- Better handling of conditional directives and comment block formatting
Reviewed Changes
Copilot reviewed 53 out of 55 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test files (various *_format.sql) | Updated expected formatting output for various SQL patterns including bind variables, directives, and query structures |
| SqlFormatterTest.kt | Added comprehensive test cases for new SQL formatting scenarios |
| SqlBlockGenerator.kt | Enhanced block generation logic for handling conditional loops and query groups |
| SqlFormatPreProcessor.kt | Simplified SQL preprocessing by removing CREATE query type handling and improving comment formatting |
| NotQueryGroupHandler.kt | Streamlined group handling by removing dependency on group lists |
| SqlBlockRelationBuilder.kt | Refactored from SqlSetParentGroupProcessor to use builder pattern for managing block relationships |
| Various block classes | Enhanced indentation and spacing logic for conditional directives and sub-groups |
Comments suppressed due to low confidence (4)
src/main/kotlin/org/domaframework/doma/intellij/formatter/processor/SqlFormatPreProcessor.kt:33
- This import statement references CreateQueryType which is no longer used in the file. The import should be removed as the related functionality has been eliminated.
import org.domaframework.doma.intellij.formatter.util.SqlKeywordUtil
src/main/kotlin/org/domaframework/doma/intellij/formatter/handler/NotQueryGroupHandler.kt:21
- This import is no longer used since the SqlElConditionLoopCommentBlock reference was removed from the lastGroupParentConditionKeywordGroup function. The import should be removed.
import org.domaframework.doma.intellij.formatter.block.conflict.SqlConflictClauseBlock
src/main/kotlin/org/domaframework/doma/intellij/formatter/block/group/keyword/top/SqlJoinQueriesGroupBlock.kt:21
- This import is unused since SqlJoinQueriesGroupBlock now extends SqlTopQueryGroupBlock instead of SqlKeywordGroupBlock. The import should be removed.
import org.domaframework.doma.intellij.formatter.block.group.keyword.with.SqlWithQuerySubGroupBlock
src/main/kotlin/org/domaframework/doma/intellij/formatter/block/group/keyword/top/SqlJoinQueriesGroupBlock.kt:22
- This import is unused since IndentType is no longer referenced in this file after the class hierarchy change. The import should be removed.
import org.domaframework.doma.intellij.formatter.util.SqlBlockFormattingContext
Description
This PR addresses issue #353 by improving SQL formatting behavior for multiple CASE expressions and enhancing overall SQL formatting consistency.
Related Issues
Fixes #353
Changes
line-breaking behavior