Add not equal comparator (!=)

The `qb.Cmp` lacks `not equal` methods related to the operator `!=`
even though the documentation
https://docs.scylladb.com/getting-started/dml/#select-statement mentions
it.

Closes: #114

Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
This commit is contained in:
pierdipi
2019-11-03 10:01:59 +01:00
parent 75adfd59ee
commit 6f13526544
2 changed files with 75 additions and 0 deletions

View File

@@ -103,6 +103,16 @@ func TestCmp(t *testing.T) {
S: "like LIKE (?,?)",
N: []string{"like_0", "like_1"},
},
{
C: Ne("ne"),
S: "ne!=?",
N: []string{"ne"},
},
{
C: NeTuple("ne", 3),
S: "ne!=(?,?,?)",
N: []string{"ne_0", "ne_1", "ne_2"},
},
// Custom bind names
{
@@ -145,6 +155,11 @@ func TestCmp(t *testing.T) {
S: "cntKey CONTAINS KEY ?",
N: []string{"name"},
},
{
C: NeNamed("ne", "name"),
S: "ne!=?",
N: []string{"name"},
},
// Literals
{
@@ -175,6 +190,10 @@ func TestCmp(t *testing.T) {
C: ContainsLit("cnt", "litval"),
S: "cnt CONTAINS litval",
},
{
C: NeLit("ne", "litval"),
S: "ne!=litval",
},
// Functions
{
@@ -214,6 +233,11 @@ func TestCmp(t *testing.T) {
S: "eq>=maxTimeuuid(?)",
N: []string{"arg0"},
},
{
C: NeFunc("ne", Fn("fn", "arg0", "arg1", "arg2")),
S: "ne!=fn(?,?,?)",
N: []string{"arg0", "arg1", "arg2"},
},
}
buf := bytes.Buffer{}