qb: tuples now returns the correct names
The names are auto generated in the form param_0, param_1, ...
This commit is contained in:
committed by
Michal Matczuk
parent
219bceab51
commit
1fda6f1e29
11
qb/value.go
11
qb/value.go
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user