-
Notifications
You must be signed in to change notification settings - Fork 0
Fix SQL formatting rules for JSON columns #408
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 rules for JSON columns #408
Conversation
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 specifically for JSON columns and array parameters by improving how operators and array brackets are handled.
- Fixed unnecessary spaces being inserted between JSON operators (->>, @>, etc.) when accessing properties from JSON columns
- Improved array parameter formatting by ensuring array closing brackets
]are handled correctly and not treated as escape characters - Added specific handling for ARRAY expressions with proper indentation and spacing
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/testData/sql/formatter/*.sql | Test data files showing before/after formatting with JSON operators and array parameters |
| src/test/kotlin/.../SqlFormatterTest.kt | Added test case for comparison operators formatting |
| src/main/kotlin/.../SqlBlockGenerator.kt | Added logic to detect ARRAY keywords and create proper block types |
| src/main/kotlin/.../CommaRawClauseHandler.kt | Added handling for commas within array list groups |
| src/main/kotlin/.../SqlArrayWordBlock.kt | New block type for ARRAY keywords with proper indentation logic |
| src/main/kotlin/.../SqlArrayListGroupBlock.kt | New group block for array parameter lists |
| src/main/kotlin/.../SqlEscapeBlock.kt | Modified to handle array closing brackets correctly |
| src/main/kotlin/.../SqlFileBlock.kt | Updated spacing rules for JSON/SQL operators and array constructs |
| src/main/kotlin/.../comment/*.kt | Refactored comment block handling with improved utility methods |
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/block/other/SqlEscapeBlock.kt
Outdated
Show resolved
Hide resolved
...in/kotlin/org/domaframework/doma/intellij/formatter/block/group/subgroup/SqlSubGroupBlock.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlFileBlock.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlBlock.kt
Show resolved
Hide resolved
src/main/kotlin/org/domaframework/doma/intellij/formatter/block/word/SqlArrayWordBlock.kt
Show resolved
Hide resolved
…lArrayWordBlock for clarity
c7267ab to
b58e9bd
Compare
Overview
Example
Before:
After: