Skip to content

Commit

Permalink
Merge pull request #820 from systay/array_property_type
Browse files Browse the repository at this point in the history
Fixes #818: problem where properties could only be scalar
  • Loading branch information
jexp committed Aug 25, 2012
2 parents 50b3f9a + faa7d46 commit 1387de7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions cypher/CHANGES.txt
Expand Up @@ -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)
--------------------
Expand Down
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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))
Expand Down
12 changes: 12 additions & 0 deletions cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTest.scala
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 1387de7

Please sign in to comment.