[ https://issues.apache.org/jira/browse/TINKERPOP-3036?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17842459#comment-17842459 ]
Stephen Mallette commented on TINKERPOP-3036: --------------------------------------------- This was "fixed" with TINKERPOP-3056. In short, 3.6.7/3.7.2 prevents the case where you can inadvertently update an {{Element}} by throwing an error as follows: {code} gremlin> g.mergeV([(T.id):'v-1']). ......1> option(onCreate, [(T.label): 'Person', 'email': 'perso...@example.org', 'age': 12]). ......2> option(onMatch, sideEffect(property(single, 'email', 'perso...@example.org')). ......3> sideEffect(property(single, 'age', 22)).constant([:])). ......4> mergeV([(T.id):'v-2']). ......5> option(onCreate, [(T.label): 'Person', 'email': 'perso...@example.org', 'age': 13]). ......6> option(onMatch, sideEffect(property(single, 'email', 'perso...@example.org')). ......7> sideEffect(property(single, 'age', 23)).constant([:])). ......8> mergeV([(T.id):'v-3']). ......9> option(onCreate, [(T.label): 'Person', 'email': 'perso...@example.org', 'age': 14]). .....10> option(onMatch, sideEffect(property(single, 'email', 'perso...@example.org')). .....11> sideEffect(property(single, 'age', 24)).constant([:])). .....12> id() The incoming traverser for MergeVertexStep cannot be an Element Type ':help' or ':h' for help. {code} In 3.7.2, you would use the [Cardinality syntax|https://tinkerpop.apache.org/docs/current/upgrade/#_map_and_cardinality]. In 4.x, there is a breaking change that will consistently promote the matched {{Element}} to the {{option()}}. We could not make this change in earlier versions without severely breaking behavior folks rely on where they expect a {{Map}} as the incoming traverser to {{option()}}. The {{Map}} behavior was important but less expected as compared to the {{Element}}. In 4.x if you want the {{Map}} behavior you would have to label that step and {[select()}} it like: {code} g.inject(xx1, xx1, xx2). fold().as("m"). mergeE(__.select("m").limit(Scope.local,1)). option(Merge.onCreate, __.select("m").range(Scope.local, 1, 2)). option(Merge.onMatch, __.select("m").tail(Scope.local)) {code} > mergeV updating incorrect vertices and other issues > --------------------------------------------------- > > Key: TINKERPOP-3036 > URL: https://issues.apache.org/jira/browse/TINKERPOP-3036 > Project: TinkerPop > Issue Type: Bug > Affects Versions: 3.7.1 > Reporter: Kelvin Lawrence > Priority: Critical > > The following Stack Overflow post (link below) reported some issues with > mergeV when side effects and cardinality are used (as well as with 3 mergeV > steps chained together). The issue reproduces on 3.7.1 using TinkerGraph. > [https://stackoverflow.com/questions/77803485/batch-mergev-working-well-when-creating-items-but-yielding-unexpected-results-w] > > Reproduction steps > > {code:java} > gremlin> g=TinkerGraph.open().traversal() > ==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard] > gremlin> g.mergeV([(T.id):'v-1']). > ......1> option(onCreate, [(T.label): 'Person', 'email': > 'perso...@example.org', 'age': 12]). > ......2> option(onMatch, sideEffect(property(single, 'email', > 'perso...@example.org')). > ......3> sideEffect(property(single, 'age', > 22)).constant([:])). > ......4> mergeV([(T.id):'v-2']). > ......5> option(onCreate, [(T.label): 'Person', 'email': > 'perso...@example.org', 'age': 13]). > ......6> option(onMatch, sideEffect(property(single, 'email', > 'perso...@example.org')). > ......7> sideEffect(property(single, 'age', > 23)).constant([:])). > ......8> mergeV([(T.id):'v-3']). > ......9> option(onCreate, [(T.label): 'Person', 'email': > 'perso...@example.org', 'age': 14]). > .....10> option(onMatch, sideEffect(property(single, 'email', > 'perso...@example.org')). > .....11> sideEffect(property(single, 'age', > 24)).constant([:])). > .....12> id() > ==>v-3 > gremlin> g.V().valueMap(true) > ==>[id:v-2,label:Person,email:[perso...@example.org],age:[13]] > ==>[id:v-1,label:Person,email:[perso...@example.org],age:[12]] > ==>[id:v-3,label:Person,email:[perso...@example.org],age:[14]] > gremlin> g.mergeV([(T.id):'v-1']). > ......1> option(onCreate, [(T.label): 'Person', 'email': > 'perso...@example.org', 'age': 12]). > ......2> option(onMatch, sideEffect(property(single, 'email', > 'perso...@example.org')). > ......3> sideEffect(property(single, 'age', > 22)).constant([:])). > ......4> mergeV([(T.id):'v-2']). > ......5> option(onCreate, [(T.label): 'Person', 'email': > 'perso...@example.org', 'age': 13]). > ......6> option(onMatch, sideEffect(property(single, 'email', > 'perso...@example.org')). > ......7> sideEffect(property(single, 'age', > 23)).constant([:])). > ......8> mergeV([(T.id):'v-3']). > ......9> option(onCreate, [(T.label): 'Person', 'email': > 'perso...@example.org', 'age': 14]). > .....10> option(onMatch, sideEffect(property(single, 'email', > 'perso...@example.org')). > .....11> sideEffect(property(single, 'age', > 24)).constant([:])). > .....12> id() > ==>v-3 > gremlin> g.V().valueMap(true) > ==>[id:v-2,label:Person,email:[perso...@example.org],age:[24]] > ==>[id:v-1,label:Person,email:[perso...@example.org],age:[23]] > ==>[id:v-3,label:Person,email:[perso...@example.org],age:[14]] > gremlin> {code} > The query seems to be both updating values in the incorrect vertices as well > as leaving some values unchanged. -- This message was sent by Atlassian Jira (v8.20.10#820010)