Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added error when using != instead of <>

  • Loading branch information...
commit 27d2dc147806973742d43e3cef9e963028b36d42 1 parent 56f75d4
Andres Taylor authored August 23, 2012
1  cypher/CHANGES.txt
@@ -7,6 +7,7 @@ o Better type error messages
7 7
 o Renamed iterable to collection
8 8
 o Fixed #795: so that WITH keeps parameters also for empty aggregation results
9 9
 o Fixed #772: Creating nodes/relationships goes before SET, so SET can run on already created elements
  10
+o Added error when using != instead of <>
10 11
 
11 12
 1.8.M07 (2012-08-08)
12 13
 --------------------
10  cypher/src/main/scala/org/neo4j/cypher/internal/parser/v1_8/Expressions.scala
@@ -20,9 +20,12 @@
20 20
 package org.neo4j.cypher.internal.parser.v1_8
21 21
 
22 22
 import org.neo4j.cypher.internal.commands._
  23
+import org.neo4j.cypher.SyntaxException
23 24
 
24 25
 trait Expressions extends Base with ParserPattern with Predicates with StringLiteral {
25  
-  def expression: Parser[Expression] = term ~ rep("+" ~ term | "-" ~ term) ^^ {
  26
+  def expression: Parser[Expression] =
  27
+
  28
+    term ~ rep("+" ~ term | "-" ~ term) ^^ {
26 29
     case head ~ rest =>
27 30
       var result = head
28 31
       rest.foreach {
@@ -86,7 +89,10 @@ trait Expressions extends Base with ParserPattern with Predicates with StringLit
86 89
   def createProperty(entity: String, propName: String): Expression
87 90
 
88 91
   def nullableProperty: Parser[Expression] = (
89  
-    property <~ "?" ^^ (p => new Nullable(p) with DefaultTrue) |
  92
+    property ~> "!=" ^^^ (throw new SyntaxException("Cypher does not support != for inequality comparisons. " +
  93
+      "It's used for nullable properties instead.\n" +
  94
+      "You probably meant <> instead. Read more about this in the operators chapter in the manual.")) |
  95
+      property <~ "?" ^^ (p => new Nullable(p) with DefaultTrue) |
90 96
       property <~ "!" ^^ (p => new Nullable(p) with DefaultFalse))
91 97
 
92 98
   def extract: Parser[Expression] = ignoreCase("extract") ~> parens(identity ~ ignoreCase("in") ~ expression ~ ":" ~ expression) ^^ {
6  cypher/src/test/scala/org/neo4j/cypher/ErrorMessagesTest.scala
@@ -214,7 +214,11 @@ class ErrorMessagesTest extends ExecutionEngineHelper with Assertions with Strin
214 214
       "Expected `users` to be a Node but it was a Collection")
215 215
   }
216 216
 
217  
-
  217
+  @Test def warn_about_exclamation_mark() {
  218
+    expectError(
  219
+      "start n=node(0) where n.foo != 2 return n",
  220
+      "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.")
  221
+  }
218 222
 
219 223
   private def expectError[T <: CypherException](query: String, expectedError: String)(implicit manifest: Manifest[T]): T = {
220 224
     val error = intercept[T](engine.execute(query).toList)

0 notes on commit 27d2dc1

Please sign in to comment.
Something went wrong with that request. Please try again.