Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented Jul 1, 2025

Support formatting for upsert statements using the ON CONFLICT DO [NOTHING | UPDATE] syntax.
This includes proper indentation and line breaking rules for ON CONFLICT, optional ON CONSTRAINT, and the DO clause with its associated update logic.

@xterao xterao self-assigned this Jul 1, 2025
@xterao xterao changed the base branch from main to feature/sql-format-official-version July 1, 2025 09:00
@xterao xterao force-pushed the feature/sql-format-support-on-conflict branch from 0ee229d to 19261b7 Compare July 1, 2025 09:05
@xterao xterao force-pushed the feature/sql-format-support-on-conflict branch from 19261b7 to 7be9abb Compare July 1, 2025 09:13
@xterao xterao requested a review from Copilot July 1, 2025 09:14
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.

Pull Request Overview

This PR introduces enhanced formatting support for SQL upsert statements using the ON CONFLICT clause. The updates include new test cases for various ON CONFLICT patterns, modifications to how conflict and DO clauses are handled in formatter block utilities, and minor refactoring in test configuration for consistent file naming.

Reviewed Changes

Copilot reviewed 34 out of 38 changed files in this pull request and generated 1 comment.

File Description
src/test/testData/sql/formatter/InsertConflictUpdate*.sql Added/updated tests to verify proper formatting of INSERT statements with ON CONFLICT clauses.
src/test/kotlin/org/domaframework/doma/intellij/formatter/SqlFormatterTest.kt Updated test naming using a new formatDataPrefix variable for consistency.
src/main/kotlin/org/domaframework/doma/intellij/formatter/util/SqlBlockUtil.kt Introduced and refined formatting handling for conflict-related blocks (e.g. CONFLICT, DO, etc.).
Other Kotlin formatter and block files Various adjustments and import refactorings to support new conflict clause support in SQL formatting.
Comments suppressed due to low confidence (2)

src/test/kotlin/org/domaframework/doma/intellij/formatter/SqlFormatterTest.kt:30

  • [nitpick] Consider adding a brief inline comment explaining the purpose of the formatDataPrefix variable to clarify its role in constructing expected test filenames.
    private val formatDataPrefix = "_format"

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/group/keyword/update/SqlUpdateValueGroupBlock.kt:52

  • [nitpick] Consider expanding or updating this TODO comment to indicate a plan for creating a dedicated class for update values to improve clarity and maintainability.
            // TODO Update Values用のクラスを作る

@xterao xterao linked an issue Jul 1, 2025 that may be closed by this pull request
@xterao xterao force-pushed the feature/sql-format-support-on-conflict branch from 51821f2 to 03edac5 Compare July 1, 2025 09:28
@xterao xterao merged commit 503b77d into feature/sql-format-official-version Jul 2, 2025
5 checks passed
@xterao xterao deleted the feature/sql-format-support-on-conflict branch July 2, 2025 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for ON CONFLICT DO [NOTHING | UPDATE] Syntax Formatting

2 participants