qb: tuples now returns the correct names

The names are auto generated in the form param_0, param_1, ...
This commit is contained in:
Henrik Johansson
2019-05-14 10:58:37 +02:00
committed by Michal Matczuk
parent 219bceab51
commit 1fda6f1e29
6 changed files with 25 additions and 18 deletions

View File

@@ -4,7 +4,10 @@
package qb
import "bytes"
import (
"bytes"
"strconv"
)
// value is a CQL value expression for use in an initializer, assignment,
// or comparison.
@@ -29,14 +32,18 @@ type tupleParam struct {
}
func (t tupleParam) writeCql(cql *bytes.Buffer) (names []string) {
baseName := string(t.param) + "_"
cql.WriteByte('(')
for i := 0; i < t.count-1; i++ {
cql.WriteByte('?')
cql.WriteByte(',')
names = append(names, baseName+strconv.Itoa(i))
}
cql.WriteByte('?')
cql.WriteByte(')')
return []string{string(t.param)}
names = append(names, baseName+strconv.Itoa(t.count-1))
return
}
// lit is a literal CQL value.