You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by "spmallette (via GitHub)" <gi...@apache.org> on 2023/07/18 10:18:14 UTC

[GitHub] [tinkerpop] spmallette commented on a diff in pull request #2127: TINKERPOP-2957 allow cardinality to be specified for mergeV()

spmallette commented on code in PR #2127:
URL: https://github.com/apache/tinkerpop/pull/2127#discussion_r1266565667


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java:
##########
@@ -2554,21 +2557,30 @@ public default GraphTraversal<S, E> property(final VertexProperty.Cardinality ca
      */
     public default GraphTraversal<S, E> property(final Object key, final Object value, final Object... keyValues) {
         if (key instanceof VertexProperty.Cardinality) {
-            if (value instanceof Map) { //Handle the property(Cardinality, Map) signature
-                final Map<Object, Object> map = (Map)value;
+            if (value instanceof Map) {
+                // Handle the property(Cardinality, Map) signature
+                final Map<Object, Object> map = (Map) value;
                 for (Map.Entry<Object, Object> entry : map.entrySet()) {
-                    property(key, entry.getKey(), entry.getValue());
+                    final Object val = entry.getValue();
+                    if (val instanceof CardinalityValueTraversal) {
+                        final CardinalityValueTraversal cardVal = (CardinalityValueTraversal) val;
+                        property(cardVal.getCardinality(), entry.getKey(), cardVal.getValue());
+                    } else {
+                        property(key, entry.getKey(), entry.getValue());

Review Comment:
   hmm, that's right. it seems that has always been a problem. changing it to prevent traversal construction if you provide that sort of input.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org