Skip to content

Commit d921210

Browse files
committed
Fix SQL formatting to ensure proper line breaks for nested subgroup blocks
1 parent abb8bd5 commit d921210

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

src/main/kotlin/org/domaframework/doma/intellij/formatter/processor/SqlFormatPreProcessor.kt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,7 @@ class SqlFormatPreProcessor : PreFormatProcessor {
9393
}
9494

9595
SqlTypes.LEFT_PAREN -> {
96-
newKeyword =
97-
if (createQueryType == CreateQueryType.TABLE) {
98-
getNewLineString(it.prevSibling, getUpperText(it))
99-
} else if (keywordIndex > 0) {
100-
if (listOf(
101-
"insert",
102-
"into",
103-
"all",
104-
).contains(replaceKeywordList[keywordIndex - 1].text.lowercase())
105-
) {
106-
getNewLineString(it.prevSibling, getUpperText(it))
107-
} else {
108-
getUpperText(it)
109-
}
110-
} else {
111-
getUpperText(it)
112-
}
96+
newKeyword = getNewLineString(it.prevSibling, getUpperText(it))
11397
}
11498

11599
SqlTypes.RIGHT_PAREN -> {

src/test/testData/sql/formatter/WithUnionAll.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
with tables AS ( ( SELECT top, no_pre_as AS AS_NAME, pre_as, clm3 from demo
1+
with tables AS (( SELECT top, no_pre_as AS AS_NAME, pre_as, clm3 from demo
22
WHERE id = /*# "block" */ )
33
UNION ALL ( SELECT id2, no_pre_as2 AS AS_NAME2, pre_as2 FROM demo2
4-
WHERE id2 = /*# "block2" */ ) )
4+
WHERE id2 = /*# "block2" */ ))
55
SELECT query.id3
66
, query.no_pre_as3 AS AS_NAME3
77
, query.pre_as3

0 commit comments

Comments
 (0)