[
https://issues.apache.org/jira/browse/TINKERPOP-2959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17901990#comment-17901990
]
ASF GitHub Bot commented on TINKERPOP-2959:
-------------------------------------------
andreachild commented on code in PR #2919:
URL: https://github.com/apache/tinkerpop/pull/2919#discussion_r1863944257
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java:
##########
@@ -2388,14 +2879,39 @@ public default GraphTraversal<S, E> hasId(final Object
id, final Object... other
// as ids are unrolled when it's in array, they should also be
unrolled when it's a list.
// this also aligns with behavior of hasId() when it's pushed
down to g.V() (TINKERPOP-2863)
ids.addAll((Collection<?>) id);
- } else
+ } else {
ids.add(id);
+ }
// unrolling ids from lists works cleaner with Collection too, as
otherwise they will need to
// be turned into array first
if (otherIds != null) {
for (final Object i : otherIds) {
- if (id instanceof Object[]) {
+ // to retain existing behavior, GValue's containing
collections are unrolled by 1 layer.
+ // For example, GValue.of([1, 2]) is processed to
[GValue.of(1), GValue.of(2)]
+ if(i instanceof GValue) {
+ Object value = ((GValue) i).get();
+ if (i instanceof Object[]) {
+ for (Object o : (Object[]) value) {
Review Comment:
Nit: can this loop be replaced with
`ids.addAll(Arrays.asList(GValue.ensureGValues((Object[]) value)));`?
```
if (value instanceof Object[]) {
ids.addAll(Arrays.asList(GValue.ensureGValues((Object[]) value)));
} else if(value instanceof Collection) {
ids.addAll(Arrays.asList(GValue.ensureGValues(((Collection<?>)
value).toArray())));
} else {
ids.add(i);
}
```
> Allow the grammar to support parameters
> ---------------------------------------
>
> Key: TINKERPOP-2959
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2959
> Project: TinkerPop
> Issue Type: Improvement
> Components: language
> Affects Versions: 3.6.4
> Reporter: Stephen Mallette
> Assignee: Stephen Mallette
> Priority: Major
> Fix For: 3.7.0
>
>
> Allow the grammar to support parameters similar to how the groovy engine does
> like, {{g.inject(x,y,z)}}. Doing this will make it easier for a transition
> away from the groovy engine as a lot of Gremlin in the world today uses
> parameters. The grammar may have to come with some limitations though as
> groovy is wide open in terms of what can be treated as a variable. Probably
> going to keep parameters tied to primitives, collections and tokens/enums
> like {{Order}} and {{Scope}}. Collections themselves will not contain
> parameters and things like a {{Traversal}} or {{P}} cannot be treated as one.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)