refactor(format): subqueries and CTE lists on Doc-IR; fix CTE commas with trailing style
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user