qb: json support
This commit is contained in:
committed by
Michal Matczuk
parent
eadf9b5427
commit
31ae81aba6
14
qb/insert.go
14
qb/insert.go
@@ -24,6 +24,7 @@ type InsertBuilder struct {
|
||||
columns []initializer
|
||||
unique bool
|
||||
using using
|
||||
json bool
|
||||
}
|
||||
|
||||
// Insert returns a new InsertBuilder with the given table name.
|
||||
@@ -43,6 +44,13 @@ func (b *InsertBuilder) ToCql() (stmt string, names []string) {
|
||||
cql.WriteString(b.table)
|
||||
cql.WriteByte(' ')
|
||||
|
||||
if b.json {
|
||||
// Ignore everything else since it goes into the Json
|
||||
cql.WriteString("JSON ?")
|
||||
stmt = cql.String()
|
||||
return
|
||||
}
|
||||
|
||||
cql.WriteByte('(')
|
||||
for i, c := range b.columns {
|
||||
cql.WriteString(c.column)
|
||||
@@ -76,6 +84,12 @@ func (b *InsertBuilder) Into(table string) *InsertBuilder {
|
||||
return b
|
||||
}
|
||||
|
||||
// Json sets the Json clause of the query.
|
||||
func (b *InsertBuilder) Json() *InsertBuilder {
|
||||
b.json = true
|
||||
return b
|
||||
}
|
||||
|
||||
// Columns adds insert columns to the query.
|
||||
func (b *InsertBuilder) Columns(columns ...string) *InsertBuilder {
|
||||
for _, c := range columns {
|
||||
|
||||
Reference in New Issue
Block a user