Skip to content

Commit 7af45c1

Browse files
committed
Revise the test data to align with DOMA’s template parsing rules.
1 parent 852b911 commit 7af45c1

16 files changed

+76
-90
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
@@ -110,6 +110,10 @@ class SqlFormatterTest : BasePlatformTestCase() {
110110
formatSqlFile("Update.sql", "Update$formatDataPrefix.sql")
111111
}
112112

113+
fun testUpdatePopulateFormatter() {
114+
formatSqlFile("UpdatePopulate.sql", "UpdatePopulate$formatDataPrefix.sql")
115+
}
116+
113117
fun testUpdateReturningFormatter() {
114118
formatSqlFile("UpdateReturning.sql", "UpdateReturning$formatDataPrefix.sql")
115119
}

src/test/testData/sql/formatter/AlterTableAddColumn_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ ALTER TABLE /*# tableName */
55
,
66
/*%end */
77
/*%end */
8-
DROP COLUMN /*# column2.name */ /*# column2.type */
8+
DROP COLUMN /*# column2.name */ /*# column2.type */

src/test/testData/sql/formatter/ComparisonOperators_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ SELECT id
2121
tags && ARRAY[/*%for property : properties */
2222
/* property */'property'
2323
/*%if property_has_next*/
24-
,
24+
,
2525
/*%end*/
2626
/*%end*/] AS is_urgent
2727
, ARRAY['tag1', 'tag2'] <@ tags AS has_all_tags

src/test/testData/sql/formatter/ConditionalSubquery.sql

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
SELECT e.id
22
, e.name
3-
,
4-
/*%if includeSkillCount */
5-
( SELECT COUNT(DISTINCT es.skill_id)
6-
FROM employee_skills es
7-
/*%if onlyActiveSkills */
8-
INNER JOIN skills sk ON es.skill_id = sk.id
9-
WHERE es.employee_id = e.id
10-
AND sk.is_active = true
11-
/*%if skillCategories != null && skillCategories.size() > 0 */
12-
AND sk.category IN /* skillCategories */('technical', 'management')
13-
/*%end*/
14-
/*%else*/
15-
WHERE es.employee_id = e.id
16-
/*%end*/ ),
17-
/*%end*/
18-
d.department_name
3+
, /*%if includeSkillCount */
4+
( SELECT COUNT(DISTINCT es.skill_id)
5+
FROM performance_reviews pr WHERE pr.employee_id = e.id
6+
/*%if reviewPeriod != null */
7+
AND pr.review_date BETWEEN /* reviewPeriod.startDate */'2023-01-01' AND /* reviewPeriod.endDate */'2023-12-31' /*%end*/
8+
/*%if minScore != null */
9+
AND pr.performance_score >= /* minScore */4.0
10+
/*%end*/ ) ,
11+
/*%end*/
12+
d.department_name
1913
FROM employees e
2014
INNER JOIN departments d ON e.department_id = d.id
2115
WHERE/*%if filterByHighPerformers */

src/test/testData/sql/formatter/ConditionalSubquery_format.sql

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@ SELECT e.id
22
, e.name
33
, /*%if includeSkillCount */
44
( SELECT COUNT(DISTINCT es.skill_id)
5-
FROM employee_skills es
6-
/*%if onlyActiveSkills */
7-
INNER JOIN skills sk
8-
ON es.skill_id = sk.id
9-
WHERE es.employee_id = e.id
10-
AND sk.is_active = true
11-
/*%if skillCategories != null && skillCategories.size() > 0 */
12-
AND sk.category IN /* skillCategories */('technical', 'management')
13-
/*%end*/
14-
/*%else*/
15-
WHERE es.employee_id = e.id
16-
/*%end*/ )
17-
,
5+
FROM performance_reviews pr
6+
WHERE pr.employee_id = e.id
7+
/*%if reviewPeriod != null */
8+
AND pr.review_date BETWEEN /* reviewPeriod.startDate */'2023-01-01' AND /* reviewPeriod.endDate */'2023-12-31'
9+
/*%end*/
10+
/*%if minScore != null */
11+
AND pr.performance_score >= /* minScore */4.0
12+
/*%end*/ )
13+
,
1814
/*%end*/
1915
d.department_name
2016
FROM employees e

src/test/testData/sql/formatter/LoopDirective_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ SELECT
33
/*%if column_index == 0 */
44
/* column.name */'id' AS /* column.alias */'user_id'
55
/*%else*/
6-
, /* column.name */'name' AS /* column.alias */'user_name'
6+
, /* column.name */'name' AS /* column.alias */'user_name'
77
/*%end*/
88
/*%end*/
99
FROM users

src/test/testData/sql/formatter/NestedDirectives_format.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ SELECT e.id
4343
/*%end */ -- END3
4444
/*%if sort_has_next */ -- IF8
4545
e.sort_field
46-
,
46+
,
4747
/*%end */ -- END8
4848
/*%end */ -- END2
4949
/*%else */ -- ELSE1

src/test/testData/sql/formatter/OrderByGroupWithConditionDirective.sql

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
SELECT e.id
22
-- with condition
33
, ROW_NUMBER() /*%if order */OVER(ORDER BY e.manager_id DESC)/*%end*/ AS row_num
4-
, RANK() OVER(PARTITION BY department_id
5-
/*%if order */ORDER BY e.manager_id DESC/*%end */
6-
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS rank_num
74
, DENSE_RANK() OVER(PARTITION BY department_id
8-
/*%if order */
5+
96
ORDER BY e.id ASC, e.manager_id ASC, created_at DESC
10-
/*%else */
7+
/*%if rows */
118
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING/*%end */) AS dense_rank_num
129
, SUM(amount)/*%if filter */ FILTER(WHERE status = 'active')/*%end*/ AS dept_salary_avg
1310
, COUNT(*) OVER(ORDER BY e.id, e.manager_id, created_at

src/test/testData/sql/formatter/OrderByGroupWithConditionDirective_format.sql

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@ SELECT e.id
55
OVER(ORDER BY e.manager_id DESC)
66
/*%end*/
77
AS row_num
8-
, RANK() OVER(PARTITION BY department_id
9-
/*%if order */
10-
ORDER BY e.manager_id DESC
11-
/*%end */
12-
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS rank_num
138
, DENSE_RANK() OVER(PARTITION BY department_id
14-
/*%if order */
159
ORDER BY e.id ASC, e.manager_id ASC, created_at DESC
16-
/*%else */
10+
/*%if rows */
1711
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
1812
/*%end */) AS dense_rank_num
1913
, SUM(amount)

src/test/testData/sql/formatter/SelectDirectiveTestData.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
SELECT /*%expand */ *
2-
, /*%populate */
3-
, extra
42
FROM ( SELECT * FROM users ) AS u
53
, ( SELECT tag FROM post WHERE u.usr_id = /*authr.id*/0 ) AS tag , employee
64
where common_id = /*@ example.status. CommonStatus @ id*/1

0 commit comments

Comments
 (0)