Permalink
Browse files

Fixes #818: problem where properties could only be scalar

  • Loading branch information...
systay committed Aug 25, 2012
1 parent 50b3f9a commit faa7d462f164fb8b9f252542abf1a9994a2bf38c
View
@@ -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)
--------------------
@@ -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))
@@ -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))
+ }
+
}

0 comments on commit faa7d46

Please sign in to comment.