From e2225e82672f08e16219bb5be2a7aeab39afb184 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 2 Jul 2020 14:42:09 +0100 Subject: add lacks string operator, lacks is the opposite of contains. e.g.: not contains --- internal/mapr/wherecondition.go | 5 +++++ samples/dtail.schema.json | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/internal/mapr/wherecondition.go b/internal/mapr/wherecondition.go index 5ca3c44..3ca9103 100644 --- a/internal/mapr/wherecondition.go +++ b/internal/mapr/wherecondition.go @@ -18,6 +18,7 @@ const ( StringEq QueryOperation = iota StringNe QueryOperation = iota StringContains QueryOperation = iota + StringNotContains QueryOperation = iota FloatOperation QueryOperation = iota FloatEq QueryOperation = iota FloatNe QueryOperation = iota @@ -99,6 +100,8 @@ func makeWhereConditions(tokens []token) (where []whereCondition, err error) { wc.Operation = StringNe case "contains": wc.Operation = StringContains + case "lacks": + wc.Operation = StringNotContains default: return wc, nil, errors.New(invalidQuery + "Unknown operation in 'where' clause: " + whereOp) } @@ -187,6 +190,8 @@ func (wc *whereCondition) stringClause(lValue string, rValue string) bool { return lValue != rValue case StringContains: return strings.Contains(lValue, rValue) + case StringNotContains: + return !strings.Contains(lValue, rValue) default: logger.Error("Unknown string operation", lValue, wc.Operation, rValue) } diff --git a/samples/dtail.schema.json b/samples/dtail.schema.json index 68db788..73807fc 100755 --- a/samples/dtail.schema.json +++ b/samples/dtail.schema.json @@ -43,6 +43,29 @@ } } }, + "Monitor": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Name": { + "type": "string" + }, + "Enable": { + "type": "boolean" + }, + "Files": { + "type": "string" + }, + "Outfile": { + "type": "string" + }, + "Query": { + "type": "string" + } + } + } + }, "HostKeyFile": { "type": "string" }, -- cgit v1.2.3