From 24d73b833551bbf7f9ac9528f7579e0a5e5bd515 Mon Sep 17 00:00:00 2001 From: Cole-Greer Date: Wed, 27 Nov 2024 18:27:58 -0800 Subject: [PATCH] fix feature test --- .../language/grammar/TraversalMethodVisitor.java | 13 +++++++------ .../process/traversal/dsl/graph/GraphTraversal.java | 8 -------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java index d9c4702a5e..a31b01b0c4 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java @@ -1250,15 +1250,16 @@ public Traversal visitTraversalMethod_option_Merge_Map_Cardinality(final Gremlin return this.graphTraversal.option(TraversalEnumParser.parseTraversalEnumFromContext(Merge.class, ctx.traversalMerge()), (Map) null); } - if (ctx.genericLiteralMapNullableArgument().variable() != null) { + final Object literalOrVar = antlr.argumentVisitor.visitGenericLiteralMapNullableArgument(ctx.genericLiteralMapNullableArgument()); + if (GValue.valueInstanceOf(literalOrVar, GType.MAP)) { return graphTraversal.option(TraversalEnumParser.parseTraversalEnumFromContext(Merge.class, ctx.traversalMerge()), - (Map) antlr.argumentVisitor.visitVariable(ctx.genericLiteralMapNullableArgument().variable()), + (GValue>) literalOrVar, + TraversalEnumParser.parseTraversalEnumFromContext(Cardinality.class, ctx.traversalCardinality())); + } else { + return graphTraversal.option(TraversalEnumParser.parseTraversalEnumFromContext(Merge.class, ctx.traversalMerge()), + (Map) literalOrVar, TraversalEnumParser.parseTraversalEnumFromContext(Cardinality.class, ctx.traversalCardinality())); } - - return graphTraversal.option(TraversalEnumParser.parseTraversalEnumFromContext(Merge.class, ctx.traversalMerge()), - (Map) new GenericLiteralVisitor(antlr).visitGenericLiteralMap(ctx.genericLiteralMapNullableArgument().genericLiteralMap()), - TraversalEnumParser.parseTraversalEnumFromContext(Cardinality.class, ctx.traversalCardinality())); } /** diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java index 06a382d179..77c4b838e6 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java @@ -4554,14 +4554,6 @@ public default GraphTraversal option(final M token, final GValue GraphTraversal option(final Merge merge, final GValue> m, final VertexProperty.Cardinality cardinality) { this.asAdmin().getGremlinLang().addStep(GraphTraversal.Symbols.option, merge, m, cardinality); - final Map map = m.get(); - - // do explicit cardinality for every single pair in the map - for (Object k : map.keySet()) { - final Object o = map.get(k); - if (!(o instanceof CardinalityValueTraversal)) - map.put(k, new CardinalityValueTraversal(cardinality, o)); - } ((TraversalOptionParent) this.asAdmin().getEndStep()).addChildOption((M) merge, (Traversal.Admin) new ConstantTraversal<>(m).asAdmin()); return this; }