diff --git a/qb/select.go b/qb/select.go index bc6ed74..73fed17 100644 --- a/qb/select.go +++ b/qb/select.go @@ -10,7 +10,6 @@ package qb import ( "bytes" "fmt" - "strings" ) // Order specifies sorting order. @@ -54,7 +53,11 @@ func (b *SelectBuilder) ToCql() (stmt string, names []string) { cql.WriteString("DISTINCT ") b.distinct.writeCql(&cql) case len(b.groupBy) > 0: - cql.WriteString(strings.Join(append(b.groupBy, b.columns...), ",")) + b.groupBy.writeCql(&cql) + if len(b.columns) != 0 { + cql.WriteByte(',') + b.columns.writeCql(&cql) + } case len(b.columns) == 0: cql.WriteByte('*') default: diff --git a/qb/utils.go b/qb/utils.go index 8b78b2b..ffa4ab4 100644 --- a/qb/utils.go +++ b/qb/utils.go @@ -6,7 +6,6 @@ package qb import ( "bytes" - "strings" ) // placeholders returns a string with count ? placeholders joined with commas. @@ -25,5 +24,10 @@ func placeholders(cql *bytes.Buffer, count int) { type columns []string func (cols columns) writeCql(cql *bytes.Buffer) { - cql.WriteString(strings.Join(cols, ",")) + for i, c := range cols { + cql.WriteString(c) + if i < len(cols)-1 { + cql.WriteByte(',') + } + } }