From 3a986a408e9ff4e927044e33af3245bdf0c6265f Mon Sep 17 00:00:00 2001 From: "Christian G. Warden" Date: Fri, 8 Dec 2023 20:27:47 -0600 Subject: [PATCH] Honor Wrap Flag When Formatting List of SELECT Fields --- formatter/visitors.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/formatter/visitors.go b/formatter/visitors.go index 8e1b043..3daf27d 100644 --- a/formatter/visitors.go +++ b/formatter/visitors.go @@ -772,11 +772,15 @@ func (v *FormatVisitor) VisitFieldNameAlias(ctx *parser.FieldNameAliasContext) i } func (v *FormatVisitor) VisitSelectList(ctx *parser.SelectListContext) interface{} { + sep := ", " + if v.wrap { + sep = ",\n" + } selectEntries := []string{} for _, p := range ctx.AllSelectEntry() { selectEntries = append(selectEntries, v.visitRule(p).(string)) } - return strings.Join(selectEntries, ",\n") + return strings.Join(selectEntries, sep) } func (v *FormatVisitor) VisitSubFieldList(ctx *parser.SubFieldListContext) interface{} {