refactor(format): subqueries and CTE lists on Doc-IR; fix CTE commas with trailing style

This commit is contained in:
Hein
2026-10-06 14:57:21 +02:00
parent 488801b8b1
commit e9c0d52ae9
5 changed files with 69 additions and 50 deletions
+18
View File
@@ -710,3 +710,21 @@ func TestSelectWrapBrokenHonoursCommaStyle(t *testing.T) {
t.Errorf("leading commas expected when broken:\n%s", got)
}
}
func TestMultiCTETrailingCommas(t *testing.T) {
src := "with a as (select 1), b as (select 2) select * from a, b"
st := config.Default()
st.Commas = config.CommaTrailing
got := File(parser.Parse(src), st)
if !strings.Contains(got, "a AS (") || !strings.Contains(got, "),\n") {
t.Errorf("trailing comma between CTEs expected:\n%s", got)
}
if err := VerifySafe(src, got, st); err != nil {
t.Errorf("safety gate: %v\n%s", err, got)
}
st.Commas = config.CommaLeading
got = File(parser.Parse(src), st)
if !strings.Contains(got, ",b AS (") {
t.Errorf("leading comma expected:\n%s", got)
}
}