Current Behavior: Gremlin does not convert String argument to its equivalent non-String datatype
Steps to Reproduce:
start gremlin.bat in windows
Execute below commands to load GraphOfTheGods
gremlin> graph = JanusGraphFactory.open('conf/janusgraph-inmemory.properties')
gremlin> GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true)
gremlin> g = graph.traversal()
Test the query.
gremlin> g.V().has('age','4500').valueMap()
==>[name:[neptune],age:[4500]]
Test the below query.
gremlin> g.V().has('name','neptune').out().in().has('age','4500').valueMap()
Result is Empty
Test the same query, now instead using String for age use the actual datatype
gremlin> g.V().has('name','neptune').out().in().has('age',4500).valueMap()
==>[name:[neptune],age:[4500]]
==>[name:[neptune],age:[4500]]
==>[name:[neptune],age:[4500]]
The issue exists in all the versions of gremlin.
The issue can also be reproduced with other datatypes such UUID, date etc.
I also changed the example-common program(PSA) to check if the issue is in gremlin console or the gremlin API.
In the example program I tested with adding UUID and date fields in schema, the issue got reproduced for those datatypes as well in the java program.
paste stack trace here
Hi @pratikjain1991, thanks for reporting!
I tested the same scenario with TinkerGraph to find out if this is actually JanusGraph or TinkerPop related. In the case of TinkerGraph, string literals are never accepted as integer values so even step 3 in your explanation returns an empty result.
This makes me think that the difference lies in the implementation of JanusGraphStep. This step provides an entry point to the traversal and is handled specially. That means the first step is actually what operates out of specification by accepting string literals.
Didn't know that JanusGraph converts string arguments to the expected data type like. I think though that we should not also add this behavior for later parts of the traversal, but instead completely stop doing it as it's unexpected behavior in my opinion. If you define an age property with a data type int then it shouldn't work when you provide a string argument.
So, I agree with @rngcntr that the first step here isn't behaving as expected and should therefore be changed.
I Upvote this issue if there's such a thing here.
Most helpful comment
Didn't know that JanusGraph converts string arguments to the expected data type like. I think though that we should not also add this behavior for later parts of the traversal, but instead completely stop doing it as it's unexpected behavior in my opinion. If you define an
ageproperty with a data typeintthen it shouldn't work when you provide astringargument.So, I agree with @rngcntr that the first step here isn't behaving as expected and should therefore be changed.