Skip to content

Commit 9251d08

Browse files
committed
Adjust SQL formatting to ensure consistent spacing for block comments and expressions
1 parent 66bed16 commit 9251d08

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlFileBlock.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,26 @@ class SqlFileBlock(
424424
SqlTypes.BLOCK_COMMENT_START,
425425
SqlTypes.BLOCK_COMMENT_CONTENT,
426426
Spacing.createSpacing(0, 0, 0, true, 0),
427+
).withSpacing(
428+
SqlTypes.BLOCK_COMMENT_START,
429+
SqlTypes.EL_ID_EXPR,
430+
Spacing.createSpacing(1, 1, 0, true, 0),
431+
).withSpacing(
432+
SqlTypes.BLOCK_COMMENT_START,
433+
SqlTypes.EL_PRIMARY_EXPR,
434+
Spacing.createSpacing(1, 1, 0, true, 0),
435+
).withSpacing(
436+
SqlTypes.BLOCK_COMMENT_START,
437+
SqlTypes.EL_STRING,
438+
Spacing.createSpacing(1, 1, 0, true, 0),
439+
).withSpacing(
440+
SqlTypes.BLOCK_COMMENT_START,
441+
SqlTypes.EL_NUMBER,
442+
Spacing.createSpacing(1, 1, 0, true, 0),
443+
).withSpacing(
444+
SqlTypes.BLOCK_COMMENT_START,
445+
SqlTypes.BOOLEAN,
446+
Spacing.createSpacing(1, 1, 0, true, 0),
427447
).withSpacing(
428448
SqlTypes.BLOCK_COMMENT_CONTENT,
429449
SqlTypes.BLOCK_COMMENT_END,

src/test/testData/sql/formatter/Select.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,7 @@ AS nearest
5050
OR n.neighbormode = 'Primary')
5151
AND ( (x.TYPE = 'Star'
5252
AND x.TYPE = 'Galaxy') OR x.modelmag_g BETWEEN 10 AND 21)
53+
OR status =
54+
/* status */'active'
5355
GROUP BY n.objid ) AS nbor ON o.objid = nbor.objid
5456
WHERE o.objid IN /* params */(1, 2, 3)

src/test/testData/sql/formatter/Select_format.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ SELECT COUNT(DISTINCT x) AS count_x
5454
AND ((x.TYPE = 'Star'
5555
AND x.TYPE = 'Galaxy')
5656
OR x.modelmag_g BETWEEN 10 AND 21)
57+
OR status = /* status */'active'
5758
GROUP BY n.objid ) AS nbor
5859
ON o.objid = nbor.objid
5960
WHERE o.objid IN /* params */(1, 2, 3)

0 commit comments

Comments
 (0)