Skip to content

Commit

Permalink
fix failing feature tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cole-Greer committed Nov 28, 2024
1 parent daba1d1 commit 6a8d0de
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ public GraphTraversal visitTraversalMethod_mergeE_Map(final GremlinParser.Traver
final Object literalOrVar = antlr.argumentVisitor.visitGenericLiteralMapNullableArgument(ctx.genericLiteralMapNullableArgument());
if (GValue.valueInstanceOf(literalOrVar, GType.MAP))
return graphTraversal.mergeE((GValue<Map<Object, Object>>) literalOrVar);
else if (GValue.valueInstanceOf(literalOrVar, GType.UNKNOWN) && ((GValue) literalOrVar).get() == null)
return graphTraversal.mergeE(GValue.ofMap(((GValue) literalOrVar).getName(), null));
else
return graphTraversal.mergeE((Map) literalOrVar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public GraphTraversal visitTraversalSourceSpawnMethod_mergeV_Map(final GremlinPa
final Object literalOrVar = antlr.argumentVisitor.visitGenericLiteralMapNullableArgument(ctx.genericLiteralMapNullableArgument());
if (GValue.valueInstanceOf(literalOrVar, GType.MAP))
return this.traversalSource.mergeV((GValue) literalOrVar);
else if (GValue.valueInstanceOf(literalOrVar, GType.UNKNOWN) && ((GValue) literalOrVar).get() == null)
return this.traversalSource.mergeV((GValue) GValue.ofMap(((GValue) literalOrVar).getName(), null));
else
return this.traversalSource.mergeV((Map) literalOrVar);
}
Expand Down Expand Up @@ -162,6 +164,8 @@ public GraphTraversal visitTraversalSourceSpawnMethod_mergeE_Map(final GremlinPa
final Object literalOrVar = antlr.argumentVisitor.visitGenericLiteralMapNullableArgument(ctx.genericLiteralMapNullableArgument());
if (GValue.valueInstanceOf(literalOrVar, GType.MAP))
return this.traversalSource.mergeE((GValue) literalOrVar);
else if (GValue.valueInstanceOf(literalOrVar, GType.UNKNOWN) && ((GValue) literalOrVar).get() == null)
return this.traversalSource.mergeE((GValue) GValue.ofMap(((GValue) literalOrVar).getName(), null));
else
return this.traversalSource.mergeE((Map) literalOrVar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@
import org.apache.tinkerpop.gremlin.util.CollectionUtil;
import org.apache.tinkerpop.gremlin.util.function.ConstantSupplier;

import java.lang.reflect.Array;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -2888,7 +2887,31 @@ public default GraphTraversal<S, E> hasId(final Object id, final Object... other
// 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) {
if(o instanceof GValue) {
ids.add(o);
} else {
ids.add(GValue.of(null, o));
}
}
} else if(value instanceof Collection) {
for (Object o : (Collection<?>) value) {
if(o instanceof GValue) {
ids.add(o);
} else {
ids.add(GValue.of(null, o));
}
}
} else {
ids.add(i);
}
}
else if (i instanceof Object[]) {
Collections.addAll(ids, (Object[]) i);
} else if (i instanceof Collection) {
ids.addAll((Collection<?>) i);
Expand Down

0 comments on commit 6a8d0de

Please sign in to comment.