Browse files

Fixes #625: Values passed through WITH have the wrong type

  • Loading branch information...
1 parent b7fc3e5 commit e443b70730b4bde7d949b86b9c103f7e7d944e36 @systay committed Jun 28, 2012
View
5 cypher/CHANGES.txt
@@ -1,3 +1,8 @@
+1.8
+--------------------
+o Fixes problem when graph elements are deleted multiple times in the same query
+o Fixes #625: Values passed through WITH have the wrong type
+
1.8.M05 (2012-06-21)
--------------------
o CREATE and RELATE can now introduce path identifiers
View
10 cypher/src/main/scala/org/neo4j/cypher/internal/commands/Expression.scala
@@ -30,12 +30,12 @@ abstract class Expression extends (Map[String, Any] => Any) {
def apply(m: Map[String, Any]) = m.getOrElse(identifier.name, compute(m))
val identifier: Identifier
- def declareDependencies(extectedType: AnyType): Seq[Identifier]
- def dependencies(extectedType: AnyType): Seq[Identifier] = {
+ def declareDependencies(expectedType: AnyType): Seq[Identifier]
+ def dependencies(expectedType: AnyType): Seq[Identifier] = {
val myType = identifier.typ
- if (!extectedType.isAssignableFrom(myType))
- throw new SyntaxException(identifier.name + " expected to be of type " + extectedType + " but it is of type " + identifier.typ)
- declareDependencies(extectedType)
+ if (!expectedType.isAssignableFrom(myType))
+ throw new SyntaxException(identifier.name + " expected to be of type " + expectedType + " but it is of type " + identifier.typ)
+ declareDependencies(expectedType)
}
def rewrite(f: Expression => Expression): Expression
View
9 cypher/src/main/scala/org/neo4j/cypher/internal/symbols/SymbolTable.scala
@@ -45,10 +45,11 @@ class SymbolTable(val identifiers: Identifier*) {
def assertHas(expected: Identifier) {
identifiers.find(_.name == expected.name) match {
- case None => throwMissingKey(expected.name)
- case Some(existing) => if (!expected.typ.isAssignableFrom(existing.typ)) {
- throw new CypherTypeException("Expected `" + expected.name + "` to be a " + expected.typ + " but it was " + existing.typ)
- }
+ case None => throwMissingKey(expected.name)
+ case Some(existing) =>
+ if (!(expected.typ.isAssignableFrom(existing.typ) || existing.typ.isAssignableFrom(expected.typ))) {
+ throw new CypherTypeException("Expected `" + expected.name + "` to be a " + expected.typ + " but it was " + existing.typ)
+ }
}
}
View
7 cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTest.scala
@@ -2112,6 +2112,13 @@ RETURN x0.name?
assert(result().toList.size === 4)
}
+ @Test
+ def with_should_not_forget_original_type() {
+ val result = parseAndExecute("create a={x:8} with a.x as foo return sum(foo)")
+
+ assert(result.toList === List(Map("sum(foo)" -> 8)))
+ }
+
@Ignore("This pattern is currently not supported. Revisit when we do support it.")
@Test
def two_double_optional_paths_with_shared_relationships() {

0 comments on commit e443b70

Please sign in to comment.