Add option to add ALLOW FILTERING to the update query (#290)

This commit is contained in:
Sylwia Szunejko
2024-09-10 16:13:54 +02:00
committed by GitHub
parent c6a436b905
commit 6ba176a175
2 changed files with 17 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ type UpdateBuilder struct {
_if _if
using using
exists bool
allowFiltering bool
}
// Update returns a new UpdateBuilder with the given table name.
@@ -72,6 +73,10 @@ func (b *UpdateBuilder) ToCql() (stmt string, names []string) {
cql.WriteString("IF EXISTS ")
}
if b.allowFiltering {
cql.WriteString("ALLOW FILTERING ")
}
stmt = cql.String()
return
}
@@ -196,6 +201,12 @@ func (b *UpdateBuilder) AddFunc(column string, fn *Func) *UpdateBuilder {
return b.addValue(column, fn)
}
// AllowFiltering sets a ALLOW FILTERING clause on the query.
func (b *UpdateBuilder) AllowFiltering() *UpdateBuilder {
b.allowFiltering = true
return b
}
func (b *UpdateBuilder) addValue(column string, value value) *UpdateBuilder {
b.assignments = append(b.assignments, assignment{
column: column,