Add a right-aligned clause keyword ("river") value to ClauseBodyAlignment
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 84/100
Rechercherichtung
Beginne mit SqlScriptDom/ScriptDom/SqlServer/Settings/SqlScriptGeneratorOptions.xml und ClauseBodyAlignment.cs und verfolge anschließend die Auffüllung von Klauseln in SqlScriptDom/ScriptDom/SqlServer/ScriptGenerator/ScriptWriter.cs. Verwende Test/SqlDom/ScriptGenerator/ClauseBodyAlignmentTests.cs, einschließlich TestAlignedGroupByAndHaving, als Ausgangsbasis und ergänze Tests für die neue rechtsbündige Ausgabe, wobei Aligned als Standard beibehalten wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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).
- Vorherrschende Sprache
- GAP
- Sterne
- 277
- Forks
- 43
- Ø Merge
- 6 T. 17 Std.
- Gemergte PRs (30 T.)
- 3
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/SqlScriptDOM
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
microsoft/SqlScriptDOM#183 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 56/100
microsoft/SqlScriptDOM#226 · 1 Reaktion ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
microsoft/SqlScriptDOM#225 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 58/100
microsoft/SqlScriptDOM#224 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
microsoft/SqlScriptDOM#222 ·
Alle Issues in microsoft/SqlScriptDOM
Ähnliche Issues
-
kaliscan.com OffenN: AdGuard for iOS P3: Medium T: Ads
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
AdguardTeam/AdguardFilters#242501 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
-
[BUG] createTool tools cannot be registered with Mastra when exactOptionalPropertyTypes is enabled Offencustomer-eng status: needs triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
-
add-toolnames MCP Toolnames Toolnames checkup
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
rajbos/ai-engineering-fluency#2190 · 3 Kommentare ·
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
gajus/eslint-plugin-jsdoc#1776 · 1 Reaktion ·