qb: removed error from builder ToCql function
Builder is not in a position to validate the statement and the effort is duplicated when the query is build. The checked errors are simple and do not occur most of the time.
This commit is contained in:
17
qb/update.go
17
qb/update.go
@@ -2,8 +2,6 @@ package qb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// UPDATE reference:
|
||||
@@ -29,20 +27,7 @@ func Update(table string) *UpdateBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *UpdateBuilder) ToCql() (stmt string, names []string, err error) {
|
||||
if b.table == "" {
|
||||
err = errors.New("update statements must specify a table")
|
||||
return
|
||||
}
|
||||
if len(b.columns) == 0 {
|
||||
err = fmt.Errorf("update statements must have at least one SET clause")
|
||||
return
|
||||
}
|
||||
if len(b.where) == 0 {
|
||||
err = fmt.Errorf("update statements must have at least one WHERE clause")
|
||||
return
|
||||
}
|
||||
|
||||
func (b *UpdateBuilder) ToCql() (stmt string, names []string) {
|
||||
cql := bytes.Buffer{}
|
||||
|
||||
cql.WriteString("UPDATE ")
|
||||
|
||||
Reference in New Issue
Block a user