diff --git a/qb/cmp.go b/qb/cmp.go index 3fe357d..f1573b3 100644 --- a/qb/cmp.go +++ b/qb/cmp.go @@ -13,6 +13,7 @@ type op byte const ( eq op = iota + ne lt leq gt @@ -21,7 +22,6 @@ const ( cnt cntKey like - ne ) // Cmp if a filtering comparator that is used in WHERE and IF clauses. @@ -36,6 +36,8 @@ func (c Cmp) writeCql(cql *bytes.Buffer) (names []string) { switch c.op { case eq: cql.WriteByte('=') + case ne: + cql.WriteString("!=") case lt: cql.WriteByte('<') case leq: @@ -54,8 +56,6 @@ func (c Cmp) writeCql(cql *bytes.Buffer) (names []string) { cql.WriteString(" CONTAINS KEY ") case like: cql.WriteString(" LIKE ") - case ne: - cql.WriteString("!=") } return c.value.writeCql(cql) } diff --git a/qb/cmp_test.go b/qb/cmp_test.go index 8d8170c..feb32e0 100644 --- a/qb/cmp_test.go +++ b/qb/cmp_test.go @@ -23,6 +23,16 @@ func TestCmp(t *testing.T) { S: "eq=?", N: []string{"eq"}, }, + { + C: Ne("ne"), + S: "ne!=?", + N: []string{"ne"}, + }, + { + C: NeTuple("ne", 3), + S: "ne!=(?,?,?)", + N: []string{"ne_0", "ne_1", "ne_2"}, + }, { C: Lt("lt"), S: "lt=maxTimeuuid(?)", N: []string{"arg0"}, }, - { - C: NeFunc("ne", Fn("fn", "arg0", "arg1", "arg2")), - S: "ne!=fn(?,?,?)", - N: []string{"arg0", "arg1", "arg2"}, - }, } buf := bytes.Buffer{}