Skip to content

Commit a42e91b

Browse files
committed
Add SQL formatting test for select case with nested conditions
1 parent b1f6d04 commit a42e91b

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ class SqlFormatterTest : BasePlatformTestCase() {
170170
formatSqlFile("NestedDirectives.sql", "NestedDirectives$formatDataPrefix.sql")
171171
}
172172

173+
fun testSelectCaseEndWithConditionFormatter() {
174+
formatSqlFile("SelectCaseEndWithCondition.sql", "SelectCaseEndWithCondition$formatDataPrefix.sql")
175+
}
176+
173177
private fun formatSqlFile(
174178
beforeFile: String,
175179
afterFile: String,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Select case when div = 'A' then 'AAA'
2+
/*%if addCondition*/
3+
/*%if conditionType == 1 */when div = 'B' then 'BBB1'
4+
/*%elseif conditionType == 2 */
5+
when div = 'B' then 'BBB2'
6+
/*%end*/
7+
/*%end*/
8+
else 'CCC' end as divName
9+
from users
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
SELECT CASE WHEN div = 'A' THEN 'AAA'
2+
/*%if addCondition*/
3+
/*%if conditionType == 1 */
4+
WHEN div = 'B' THEN 'BBB1'
5+
/*%elseif conditionType == 2 */
6+
WHEN div = 'B' THEN 'BBB2'
7+
/*%end*/
8+
/*%end*/
9+
ELSE 'CCC'
10+
END AS divName
11+
FROM users

src/test/testData/sql/formatter/UpdateBindVariable_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ UPDATE /*# tableName */
33
, X2 = 2
44
, X3 = 3
55
/*%for entity : entities */
6-
, /*# entity.itemIdentifier */= /* entity.value */'abc'
6+
, /*# entity.itemIdentifier */ = /* entity.value */'abc'
77
/*%end*/
88
WHERE X = /* reportId */1

0 commit comments

Comments
 (0)