Browse files

Added error when using != instead of <>

  • Loading branch information...
1 parent b605481 commit 1a5830ba24d3117d70d4f9ca20234692eab89771 @systay committed with jexp Aug 23, 2012
View
1 cypher/CHANGES.txt
@@ -7,6 +7,7 @@ o Better type error messages
o Renamed iterable to collection
o Fixed #795: so that WITH keeps parameters also for empty aggregation results
o Fixed #772: Creating nodes/relationships goes before SET, so SET can run on already created elements
+o Added error when using != instead of <>
1.8.M07 (2012-08-08)
--------------------
View
10 cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/Expressions.scala
@@ -20,9 +20,12 @@
package org.neo4j.cypher.internal.parser.v1_8
import org.neo4j.cypher.internal.commands._
+import org.neo4j.cypher.SyntaxException
trait Expressions extends Base with ParserPattern with Predicates with StringLiteral {
- def expression: Parser[Expression] = term ~ rep("+" ~ term | "-" ~ term) ^^ {
+ def expression: Parser[Expression] =
+
+ term ~ rep("+" ~ term | "-" ~ term) ^^ {
case head ~ rest =>
var result = head
rest.foreach {
@@ -86,7 +89,10 @@ trait Expressions extends Base with ParserPattern with Predicates with StringLit
def createProperty(entity: String, propName: String): Expression
def nullableProperty: Parser[Expression] = (
- property <~ "?" ^^ (p => new Nullable(p) with DefaultTrue) |
+ property ~> "!=" ^^^ (throw new SyntaxException("Cypher does not support != for inequality comparisons. " +
+ "It's used for nullable properties instead.\n" +
+ "You probably meant <> instead. Read more about this in the operators chapter in the manual.")) |
+ property <~ "?" ^^ (p => new Nullable(p) with DefaultTrue) |
property <~ "!" ^^ (p => new Nullable(p) with DefaultFalse))
def extract: Parser[Expression] = ignoreCase("extract") ~> parens(identity ~ ignoreCase("in") ~ expression ~ ":" ~ expression) ^^ {
View
6 cypher/src/test/scala/org/neo4j/cypher/ErrorMessagesTest.scala
@@ -214,7 +214,11 @@ class ErrorMessagesTest extends ExecutionEngineHelper with Assertions with Strin
"Expected `users` to be a Node but it was a Collection")
}
-
+ @Test def warn_about_exclamation_mark() {
+ expectError(
+ "start n=node(0) where n.foo != 2 return n",
+ "Cypher does not support != for inequality comparisons. It's used for nullable properties instead.\nYou probably meant <> instead. Read more about this in the operators chapter in the manual.")
+ }
private def expectError[T <: CypherException](query: String, expectedError: String)(implicit manifest: Manifest[T]): T = {
val error = intercept[T](engine.execute(query).toList)

0 comments on commit 1a5830b

Please sign in to comment.