Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Won't Do
-
3.4.3
-
None
-
None
Description
EdgeOtherVertexStep always looks for the last vertex in the path and uses that vertex to calculate the "other" vertex (see the code). This implementation works most of the time, but it produces unexpected results if a different vertex is injected into the path between the right vertex and the call to otherV(). For example:
gremlin> G = TinkerFactory.createModern() gremlin> g = G.traversal() gremlin> g.V().has('name', 'marko').outE().as('e').V().has('name', 'peter').select('e').otherV().values('name') ==>marko ==>marko ==>marko
In the example above, otherV() returns marko because the implementation applies otherV() to V().has('name', 'peter') instead of V().has('name', 'marko')
Another example:
gremlin> g.V().has('name', 'marko').outE().as('e').otherV().select('e').otherV().path() ==>[v[1],e[9][1-created->3],v[3],e[9][1-created->3],v[1]] ==>[v[1],e[7][1-knows->2],v[2],e[7][1-knows->2],v[1]] ==>[v[1],e[8][1-knows->4],v[4],e[8][1-knows->4],v[1]]
The first .otherV() returns the right vertex, but the second one always returns v[1]. This happens because the second otherV() is applied to the result returned by the first otherV(), which seems incorrect.