Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented Apr 10, 2025

Fixed unintended SQL formatting behavior

  • Remove the space before keyword elements within functions.
  • Remove line breaks from test data of List type.
  • Prevent increased indentation when multiple columns are specified in Create or Update queries.
  • Make block comments in conditional and loop directives subject to line breaks.
  • Adjust the indentation level for bulk multi-column updates in Update queries.
  • Relocate the package for the format block
  • Delegate some processing to another class

@xterao xterao added the bug Something isn't working label Apr 10, 2025
@xterao xterao self-assigned this Apr 10, 2025
@github-actions github-actions bot added the fix Bug fixes label Apr 10, 2025
@xterao xterao linked an issue Apr 10, 2025 that may be closed by this pull request
@xterao xterao added this to the 1.0.0 Release milestone Apr 10, 2025
@xterao xterao requested a review from Copilot April 10, 2025 02:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 46 out of 46 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlOtherBlock.kt:60

  • [nitpick] The function name 'createIntendLen' appears to contain a misspelling; consider renaming it to 'createIndentLen' to improve clarity.
private fun createIntendLen(): Int {

src/main/kotlin/org/domaframework/doma/intellij/formatter/SqlFormattingModelBuilder.kt:95

  • Review the change in token mapping from white space to 'SqlTypes.NUMBER' and 'SqlTypes.STRING' for spacing configuration to ensure it aligns with the intended formatting behavior.
.withSpacing( SqlTypes.NUMBER, SqlTypes.COMMA, SqlCustomSpacingBuilder.nonSpacing,

@xterao xterao requested a review from Copilot April 10, 2025 03:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 46 out of 46 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/main/kotlin/org/domaframework/doma/intellij/formatter/SqlFormattingModelBuilder.kt:94

  • The spacing rule change from using TokenType.WHITE_SPACE to SqlTypes.NUMBER might be unintended; please double-check if this correctly reflects the desired token spacing behavior.
.withSpacing( SqlTypes.NUMBER, SqlTypes.COMMA, SqlCustomSpacingBuilder.nonSpacing, )

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlRightPatternBlock.kt:97

  • Ensure that the updated logic in 'isNewLine' (previously 'isNeedBeforeWhiteSpace') is thoroughly covered by unit tests to validate that multi-column update formatting works as intended.
fun isNewLine(lastGroup: SqlBlock?): Boolean =

@xterao
Copy link
Collaborator Author

xterao commented Apr 10, 2025

The spacing rule change from using TokenType.WHITE_SPACE to SqlTypes.NUMBER might be unintended; please double-check if this correctly reflects the desired token spacing behavior.

There is no problem with this change because the parser does not require spacing between TokenType.WHITE_SPACE and other tokens.

Ensure that the updated logic in 'isNewLine' (previously 'isNeedBeforeWhiteSpace') is thoroughly covered by unit tests to validate that multi-column update formatting works as intended.

Test case confirms that multiple columns are updated and that the column definition format is correct

@xterao xterao merged commit a99ae2c into main Apr 10, 2025
4 checks passed
@xterao xterao deleted the fix/formatter-indent branch April 10, 2025 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Formatting and indenting SQL with bind variables

2 participants