Add a right-aligned clause keyword ("river") value to ClauseBodyAlignment
還沒有人認領這個 Issue。
評估
研究方向
從 SqlScriptDom/ScriptDom/SqlServer/Settings/SqlScriptGeneratorOptions.xml 和 ClauseBodyAlignment.cs 開始,接著追蹤 SqlScriptDom/ScriptDom/SqlServer/ScriptGenerator/ScriptWriter.cs 中的子句填充。以 Test/SqlDom/ScriptGenerator/ClauseBodyAlignmentTests.cs(包括 TestAlignedGroupByAndHaving)為基線,新增對新的靠右對齊輸出的涵蓋,同時保留 Aligned 作為預設值。
由索引模型根據 Issue 內容生成。
描述
Feature request: right-aligned clause keywords ("river" style) as a ClauseBodyAlignment option
Is your feature request related to a problem? Please describe.
ClauseBodyAlignment currently offers Aligned and Indented. Aligned pads to the right of the clause keyword, so keywords are flush left and the clause bodies line up:
SELECT a,
COUNT(*)
FROM t
GROUP BY a
HAVING COUNT(*) > 1
ORDER BY a;
There is no way to get the widely used variant where the keywords themselves are right-aligned into the gutter:
SELECT a,
COUNT(*)
FROM t
GROUP BY a
HAVING COUNT(*) > 1
ORDER BY a;
This is a common house style, and for anyone who wants it, ScriptDOM's script generator currently can't produce it at all — not via any combination of the existing options.
Describe the solution you'd like
A third value on the existing ClauseBodyAlignment enum, for example KeywordRightAligned (or River, if you prefer the common name for the style), leaving Aligned as the default so no existing output changes.
The reason this is likely a small change: both styles place the clause body in exactly the same column. In the example above, the body column is 9 in both cases, derived from the width of the widest clause keyword in the statement (GROUP BY). The gutter arithmetic that Aligned already performs is exactly what the new value needs — the only difference is whether the padding is emitted after the keyword or before it.
Concretely, the affected pieces look like:
SqlScriptDom/ScriptDom/SqlServer/Settings/SqlScriptGeneratorOptions.xml— one new<Option>entry on the existing settingSqlScriptDom/ScriptDom/SqlServer/ClauseBodyAlignment.cs— one new enum memberSqlScriptDom/ScriptDom/SqlServer/ScriptGenerator/ScriptWriter.cs— emit the alignment padding before the keyword rather than after it
There already exists a RightAlignedSeparatorElement in ScriptWriter, used to right-align leading commas so they end at the following alignment point. That is close to the same operation applied to a clause keyword, so the concept is arguably already present in the writer.
For nested constructs, the natural behaviour would be for the gutter to be computed per statement at each nesting level, matching how Aligned already scopes its alignment points.
Describe alternatives you've considered
- Post-processing the generated script. Workable in principle, since the body column is already correct: move each clause keyword's trailing padding to the front of the line. In practice it means re-deriving line structure from text, taking care not to touch lines inside multi-line string literals or block comments, and handling the existing indent of nested subqueries. That is a fragile reimplementation of information the writer already has.
- Post-processing
GenerateTokens()output. More robust than working on text, but still amounts to redoing the alignment pass outside the library. Indentedmode. Different style, doesn't address this.
Additional context
Prior art for this as a first-class formatter option:
- Oracle SQL Developer added a "Right-Align Query Keywords" formatting option in 18.1
- DataGrip has a long-standing request for the same (DBE-5419)
- Several standalone formatters implement it as their primary style
I'm using ScriptDOM directly for a small standalone T-SQL formatter, driven by SqlScriptGeneratorOptions, so this is a request against the library rather than against any particular editor integration.
Verified against main: the current Aligned output above matches the expected values in Test/SqlDom/ScriptGenerator/ClauseBodyAlignmentTests.cs (TestAlignedGroupByAndHaving).
- 主要語言
- GAP
- 星號
- 278
- 分支
- 46
- 平均合併
- 9 天 23 小時
- 30 天內合併 PR
- 2
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/SqlScriptDOM 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
microsoft/SqlScriptDOM#183 ·
-
Add a Multiline option for CASE expressions (WHEN/THEN/ELSE on their own lines)可能已有人在做 @trg-alasdair 於 10 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 56/100
microsoft/SqlScriptDOM#226 · 1 個 reaction ·
-
難度 4/5 3-5 天 新手友好度 48/100
microsoft/SqlScriptDOM#225 ·
-
難度 3/5 1-2 天 新手友好度 58/100
microsoft/SqlScriptDOM#224 ·
-
BACKUP_PRIORITY does not parse while using clause ADD REPLICA ON可能已有人在做 @ZEUSXXIV 於 53 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 68/100
microsoft/SqlScriptDOM#222 ·
查看 microsoft/SqlScriptDOM 的全部 Issue
相似的 Issue
-
Dependencies view: `getParent` loops forever on untitled documents, extension host runs out of memory可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉bug
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 1 天內回覆
-
cost-tracker: claude-opus-5-5 and claude-haiku-5-5 fall into previous-generation rate buckets (Haiku 5.5 overestimated 10x)可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 4 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
aicell-lab/bioengine#232 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
zerocracy/judges-action#2729 ·
維護者通常 8 天內回覆
-
agent/scanner bug hive/hosted-available-lke648397-260827-5n31
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆