-
Notifications
You must be signed in to change notification settings - Fork 0
Handle Blocks with the Same Name as Functions or Keywords as Word Blocks #426
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
… on previous line spacing
…ressionGroupBlock and properly handle spacing when subqueries are present
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 unintended formatting when column names are identical to SQL functions or reserved keywords by treating such identifiers as word blocks instead of applying function/keyword formatting.
- Handle escaped identifiers (e.g.,
"age",[abs]) consistently as word blocks without keyword capitalization - Improve spacing and indentation logic for escaped identifiers and conditional expressions
- Add test coverage for function names used as column identifiers
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| FunctionNameColumn.sql | Test input with function/keyword names used as columns |
| FunctionNameColumn_format.sql | Expected formatted output showing proper word block treatment |
| SqlFormatterTest.kt | Added test case for function name column formatting |
| SqlFormatVisitor.kt | Added logic to handle elements after block comment end |
| SqlBlockGenerator.kt | Added helper methods for escape detection and function name handling |
| SqlFormatPreProcessor.kt | Enhanced escape detection and keyword processing logic |
| InjectionSqlFormatter.kt | Improved base indent calculation for text blocks |
| NotQueryGroupHandler.kt | Extended condition keyword group detection |
| SqlBlockRelationBuilder.kt | Refactored top-level type checking |
| SqlFunctionGroupBlock.kt | Enhanced indentation calculation for function blocks |
| SqlEscapeBlock.kt | Improved escape block indentation and spacing logic |
| SqlTopQueryGroupBlock.kt | Added spacing logic for top-level blocks |
| SqlConditionalExpressionGroupBlock.kt | Enhanced indentation for conditional expressions |
| SqlElConditionLoopCommentBlock.kt | Fixed indentation calculations and parent detection |
| SqlElBlockCommentBlock.kt | Added keyword group block indentation support |
| SqlRightPatternBlock.kt | Improved spacing logic for conditional expressions |
| SqlFileBlock.kt | Enhanced keyword/function name detection and spacing |
| SqlBlock.kt | Improved condition loop directive detection |
| TypeUtil.kt | Centralized top-level type checking logic |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Summary
This PR fixes unintended formatting when column names are identical to SQL functions or reserved keywords. Previously, such identifiers were not treated as normal word blocks, leading to incorrect formatting results.
Relation
#423
Details
"age") are also handled consistently to prevent unwanted formatting changes.Adjustments for Escaped Identifiers:
Impact