Ken Hu created TINKERPOP-3320:
---------------------------------
Summary: hasId() is not the same as has(id)
Key: TINKERPOP-3320
URL: https://issues.apache.org/jira/browse/TINKERPOP-3320
Project: TinkerPop
Issue Type: Bug
Components: process
Affects Versions: 3.7.7
Reporter: Ken Hu
The apparent long and short forms of an ID filter behave differently when
passed a collection:
{noformat}
gremlin> g.withoutStrategies(TinkerGraphStepStrategy).V().has(id, [1])
gremlin> g.withoutStrategies(TinkerGraphStepStrategy).V().hasId([1])
==>v[1]
{noformat}
{{hasId(Collection)}} treats the collection as multiple candidate IDs, while
{{has(T.id, Collection)}} treats the collection as a single value.
This happens because hasId() explicitly supports collection unrolling
(introduced a long time ago). The question is whether these forms should remain
semantically different.
Resolution 1: Make the forms equivalent
Treat a raw collection passed to {{has(T.id, value)}} as multiple candidate
IDs, matching {{hasId(value)}}:
{noformat}
has(T.id, [1, 2]) == hasId([1, 2])
{noformat}
This resolution makes sense because hasId(value) is presented as the
ID-specific shorthand for has(T.id, value).
Resolution 2: Preserve the distinction
Continue treating a collection passed to {{has(T.id, value)}} as one value.
Multiple candidate IDs would remain explicit:
{noformat}
has(T.id, P.within([1, 2]))
{noformat}
This resolution is defensible because has(T, Object) consistently means
equality against the supplied object for all T.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)