diff --git a/pkg/format/dml_test.go b/pkg/format/dml_test.go index 5d890cf..210a3a8 100644 --- a/pkg/format/dml_test.go +++ b/pkg/format/dml_test.go @@ -694,3 +694,19 @@ func TestJoinWrap(t *testing.T) { t.Errorf("when_long long should equal always") } } + +func TestSelectWrapBrokenHonoursCommaStyle(t *testing.T) { + src := "select a, b, c from t" + st := config.Default() + st.SelectWrap = config.WrapWhenLong + st.LineWidth = 8 + st.Commas = config.CommaTrailing + got := File(parser.Parse(src), st) + if !strings.Contains(got, " a,\n") || strings.Contains(got, "\n ,b") { + t.Errorf("trailing commas expected when broken:\n%s", got) + } + st.Commas = config.CommaLeading + if got := File(parser.Parse(src), st); !strings.Contains(got, "\n ,b") { + t.Errorf("leading commas expected when broken:\n%s", got) + } +}