Skip to content

Commit 65d9df4

Browse files
committed
Fix 'ON CONFLICT' Test Case.
1 parent 573e1d4 commit 65d9df4

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class SqlSetParentGroupProcessor(
179179
return@setParentGroups if (lastGroup is SqlUpdateQueryGroupBlock && lastGroup.parentBlock is SqlDoGroupBlock) {
180180
lastGroup.parentBlock
181181
} else {
182-
history.lastOrNull()
182+
lastGroup
183183
}
184184
}
185185
return

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ class SqlFormatterTest : BasePlatformTestCase() {
6666
formatSqlFile("Insert.sql", "Insert$formatDataPrefix.sql")
6767
}
6868

69+
fun testInsertReturningFormatter() {
70+
formatSqlFile("InsertReturning.sql", "InsertReturning$formatDataPrefix.sql")
71+
}
72+
6973
fun testInsertWithBindVariableFormatter() {
7074
formatSqlFile("InsertWithBindVariable.sql", "InsertWithBindVariable$formatDataPrefix.sql")
7175
}
@@ -74,6 +78,10 @@ class SqlFormatterTest : BasePlatformTestCase() {
7478
formatSqlFile("Update.sql", "Update$formatDataPrefix.sql")
7579
}
7680

81+
fun testUpdateReturningFormatter() {
82+
formatSqlFile("UpdateReturning.sql", "UpdateReturning$formatDataPrefix.sql")
83+
}
84+
7785
fun testUpdateBindVariableFormatter() {
7886
formatSqlFile("UpdateBindVariable.sql", "UpdateBindVariable$formatDataPrefix.sql")
7987
}
@@ -82,10 +90,22 @@ class SqlFormatterTest : BasePlatformTestCase() {
8290
formatSqlFile("UpdateTupleAssignment.sql", "UpdateTupleAssignment$formatDataPrefix.sql")
8391
}
8492

93+
fun testUpdateTupleAssignmentSubQueryFormatter() {
94+
formatSqlFile("UpdateTupleAssignmentSubQuery.sql", "UpdateTupleAssignmentSubQuery$formatDataPrefix.sql")
95+
}
96+
97+
fun testUpdateTupleSubUseQueryRowFormatter() {
98+
formatSqlFile("UpdateTupleSubUseQueryRow.sql", "UpdateTupleSubUseQueryRow$formatDataPrefix.sql")
99+
}
100+
85101
fun testDeleteFormatter() {
86102
formatSqlFile("Delete.sql", "Delete$formatDataPrefix.sql")
87103
}
88104

105+
fun testDeleteReturningFormatter() {
106+
formatSqlFile("DeleteReturning.sql", "DeleteReturning$formatDataPrefix.sql")
107+
}
108+
89109
fun testInsertConflictUpdateFormatter() {
90110
formatSqlFile("InsertConflictUpdate.sql", "InsertConflictUpdate$formatDataPrefix.sql")
91111
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
insert into employee (id, username) values ( /* employees.id */0, /* employees.name */'name')
2-
on conflict (username) do nothing
2+
on conflict (username) on Constraint do nothing

src/test/testData/sql/formatter/InsertConflictNothing_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ INSERT INTO employee
33
, username)
44
VALUES ( /* employees.id */0
55
, /* employees.name */'name')
6-
ON CONFLICT (username)
6+
ON CONFLICT (username) ON CONSTRAINT
77
DO NOTHING

src/test/testData/sql/formatter/InsertConflictUpdate_format.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ ON CONFLICT (id)
1010
DO UPDATE
1111
SET name = EXCLUDED.name
1212
, email = DEFAULT
13-
WHERE employees.name IS DISTINCT
14-
FROM EXCLUDED.name
13+
WHERE employees.name IS DISTINCT FROM EXCLUDED.name
1514
RETURNING id
1615
, manager_id
1716
, name

0 commit comments

Comments
 (0)