Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes #818: problem where properties could only be scalar

  • Loading branch information...
commit faa7d462f164fb8b9f252542abf1a9994a2bf38c 1 parent 50b3f9a
@systay authored
View
1  cypher/CHANGES.txt
@@ -10,6 +10,7 @@ o Fixed #772: Creating nodes/relationships goes before SET, so SET can run on al
o Added error when using != instead of <>
o Fixed #787: Issue when comparing array properties with literal collections
o Fixes #751: Better error message for some type errors
+o Fixed #818: problem where properties could only have scalar values (they can be arrays as well)
1.8.M07 (2012-08-08)
--------------------
View
5 cypher/src/main/scala/org/neo4j/cypher/internal/commands/Expression.scala
@@ -33,7 +33,8 @@ abstract class Expression extends (Map[String, Any] => Any) {
def declareDependencies(expectedType: AnyType): Seq[Identifier]
def dependencies(expectedType: AnyType): Seq[Identifier] = {
val myType = identifier.typ
- if (!expectedType.isAssignableFrom(myType))
+ if (!expectedType.isAssignableFrom(myType) &&
+ !myType.isAssignableFrom(expectedType))
throw new SyntaxException("`%s` expected to be a %s but it is a %s".format(identifier.name, expectedType, identifier.typ))
declareDependencies(expectedType)
}
@@ -222,7 +223,7 @@ case class Property(entity: String, property: String) extends CastableExpression
}
}
- val identifier: Identifier = Identifier(entity + "." + property, ScalarType())
+ val identifier: Identifier = Identifier(entity + "." + property, AnyType())
def declareDependencies(extectedType: AnyType): Seq[Identifier] = Seq(Identifier(entity, MapType()))
def rewrite(f: (Expression) => Expression) = f(this)
def filter(f: (Expression) => Boolean) = if(f(this))
View
12 cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTest.scala
@@ -28,6 +28,7 @@ import org.neo4j.graphdb.{Path, Relationship, Direction, Node}
import org.junit.{Ignore, Test}
import org.neo4j.index.lucene.ValueContext
import org.neo4j.test.ImpermanentGraphDatabase
+import collection.mutable
class ExecutionEngineTest extends ExecutionEngineHelper {
@@ -2236,4 +2237,15 @@ RETURN x0.name?
assert(result.toList === List(Map("n" -> node)))
}
+
+ @Test
+ def array_property_should_be_accessible_as_collection() {
+ val result = parseAndExecute("START n=node(0) SET n.array = [1,2,3,4,5] RETURN tail(tail(n.array))").
+ toList.
+ head("tail(tail(n.array))").
+ asInstanceOf[mutable.WrappedArray[_]]
+
+ assert(result.toList === List(3,4,5))
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.