Batch mergeV working well when creating items, but yielding unexpected results when updating

88 views Asked by At

I used this thread Gremlin MergeV To Update an Existing Element's property and Single Cardinality as a reference to test a mergeV query that creates a vertex with some properties if its id is not found or just updates them if the id is found. Strangely enough, if I delete all vertices to start fresh, it successfully creates all 3 vertices with the correct properties. However, whenever I try to run the same query again with different property values, the output becomes really unexpected, like properties from one item going to the other. Wonder what's going wrong.

g.mergeV([(T.id):'v-1']).
    option(onCreate, [(T.label): 'Person', 'email': '[email protected]', 'age': {age}]).option(onMatch, sideEffect(property(single, 'email', '[email protected]')).sideEffect(property(single, 'age', {age})).constant([:])).
  mergeV([(T.id):'v-2']).
    option(onCreate, [(T.label): 'Person', 'email': '[email protected]', 'age': {age}]).option(onMatch, sideEffect(property(single, 'email', '[email protected]')).sideEffect(property(single, 'age', {age})).constant([:])).
  mergeV([(T.id):'v-3']).
    option(onCreate, [(T.label): 'Person', 'email': '[email protected]', 'age': {age}]).option(onMatch, sideEffect(property(single, 'email', '[email protected]')).sideEffect(property(single, 'age', {age})).constant([:])).
    id()

If, for example, I change replace '[email protected]' by '[email protected]' in both occurences of v-2, I get an output like this:

{
  "requestId": "7fd4de9f-8c25-4493-98f7-a39c0292edc5",
  "status": {
    "message": "",
    "code": 200,
    "attributes": {
      "@type": "g:Map",
      "@value": []
    }
  },
  "result": {
    "data": {
      "@type": "g:List",
      "@value": [
        {
          "@type": "g:Vertex",
          "@value": {
            "id": "v-1",
            "label": "Person",
            "properties": {
              "age": [
                {
                  "@type": "g:VertexProperty",
                  "@value": {
                    "id": {
                      "@type": "g:Int32",
                      "@value": 92892634
                    },
                    "value": {
                      "@type": "g:Int32",
                      "@value": 30
                    },
                    "label": "age"
                  }
                }
              ],
              "email": [
                {
                  "@type": "g:VertexProperty",
                  "@value": {
                    "id": {
                      "@type": "g:Int32",
                      "@value": -928922435
                    },
                    "value": "[email protected]",
                    "label": "email"
                  }
                }
              ]
            }
          }
        },
        {
          "@type": "g:Vertex",
          "@value": {
            "id": "v-2",
            "label": "Person",
            "properties": {
              "age": [
                {
                  "@type": "g:VertexProperty",
                  "@value": {
                    "id": {
                      "@type": "g:Int32",
                      "@value": 92892635
                    },
                    "value": {
                      "@type": "g:Int32",
                      "@value": 30
                    },
                    "label": "age"
                  }
                }
              ],
              "email": [
                {
                  "@type": "g:VertexProperty",
                  "@value": {
                    "id": {
                      "@type": "g:Int32",
                      "@value": -1319118437
                    },
                    "value": "[email protected]",
                    "label": "email"
                  }
                }
              ]
            }
          }
        },
        {
          "@type": "g:Vertex",
          "@value": {
            "id": "v-3",
            "label": "Person",
            "properties": {
              "age": [
                {
                  "@type": "g:VertexProperty",
                  "@value": {
                    "id": {
                      "@type": "g:Int32",
                      "@value": 92892636
                    },
                    "value": {
                      "@type": "g:Int32",
                      "@value": 30
                    },
                    "label": "age"
                  }
                }
              ],
              "email": [
                {
                  "@type": "g:VertexProperty",
                  "@value": {
                    "id": {
                      "@type": "g:Int32",
                      "@value": -1319118436
                    },
                    "value": "[email protected]",
                    "label": "email"
                  }
                }
              ]
            }
          }
        }
      ]
    },
    "meta": {
      "@type": "g:Map",
      "@value": []
    }
  }
}
0

There are 0 answers