run apache-rat on S2GRAPH-219
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/parsers/WhereParser.scala b/s2core/src/main/scala/org/apache/s2graph/core/parsers/WhereParser.scala
index 75e9657..4b9725e 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/parsers/WhereParser.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/parsers/WhereParser.scala
@@ -190,18 +190,22 @@
val in = "in|IN".r
- val contains = "contains|CONTAINS".r
-
val notIn = "not in|NOT IN".r
+ val contains = "contains|CONTAINS".r
+
def where: Parser[Where] = rep(clause) ^^ (Where(_))
def paren: Parser[Clause] = "(" ~> clause <~ ")"
- def clause: Parser[Clause] = (predicate | paren) * (and ^^^ { (a: Clause, b: Clause) => And(a, b) } | or ^^^ { (a: Clause, b: Clause) => Or(a, b) })
+ def clause: Parser[Clause] = (_not | predicate | paren) * (and ^^^ { (a: Clause, b: Clause) => And(a, b) } | or ^^^ { (a: Clause, b: Clause) => Or(a, b) })
def identWithDot: Parser[String] = repsep(ident, ".") ^^ { case values => values.mkString(".") }
+ val _not = "not|NOT".r ~ (predicate | paren) ^^ {
+ case op ~ p => Not(p)
+ }
+
val _eq = identWithDot ~ ("!=" | "=") ~ stringLiteral ^^ {
case f ~ op ~ s => if (op == "=") Eq(f, s) else Not(Eq(f, s))
}
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/parsers/WhereParserTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/parsers/WhereParserTest.scala
index 342d9c6..0ff4db1 100644
--- a/s2core/src/test/scala/org/apache/s2graph/core/parsers/WhereParserTest.scala
+++ b/s2core/src/test/scala/org/apache/s2graph/core/parsers/WhereParserTest.scala
@@ -46,6 +46,7 @@
}
val whereOpt = WhereParser().parse(sql)
+
if (whereOpt.isFailure) {
debug(whereOpt)
whereOpt.get // touch exception
@@ -138,6 +139,7 @@
f("time > 2")(true)
f("time <= 3")(true)
f("time < 2")(false)
+ f("NOT time >= 3")(false)
f("(time in (1, 2, 3) and is_blocked = true) or is_hidden = false")(false)
f("(time in (1, 2, 3) or is_blocked = true) or is_hidden = false")(true)
@@ -169,6 +171,8 @@
f(s"_from = ${tgtVertex.innerId.value} and _to = 102934")(false)
f(s"_from = -1")(false)
f(s"_from in (-1, -0.1)")(false)
+ f(s"NOT (_from = -1)")(true)
+ f(s"NOT _from contains 'a'")(true)
}
}
diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/middleware/GraphFormatWriter.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/middleware/GraphFormatWriter.scala
index 91fea62..6dcc368 100644
--- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/middleware/GraphFormatWriter.scala
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/middleware/GraphFormatWriter.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.graphql.middleware
import org.apache.s2graph.core.schema.ServiceColumn
diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/PlayJsonScalarType.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/PlayJsonScalarType.scala
index 5149d36..fc7f1ce 100644
--- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/PlayJsonScalarType.scala
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/PlayJsonScalarType.scala
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.s2graph.graphql.types
import play.api.libs.json._