gremlinrestclient icon indicating copy to clipboard operation
gremlinrestclient copied to clipboard

Creating a Edge

Open smunx opened this issue 9 years ago • 2 comments

Hi Dave, I am trying to create a edge but the weight property is not working. Even if I specify the weight its creating a edge without the property. I used your below example

>>> d = {"name": "dave", "label": "person"}
>>> p = {"name": "python", "label": "lang"}
>>> e = (d, "LIKES", p, {'weight': 1})
>>> graph.create(e)

I traced the gremlin query which was being generated. You can see the weight property is missing.

{"gremlin": "v0 = graph.addVertex(label, p0, 'name', p1, );v1 = graph.addVertex(label, p2, 'name', p3, );e0 = v1.addEdge('LIKES', v0, );graph.tx().commit();[[v0,v1], [e0]];", "bindings": {"p2": "lang", "p3": "python", "p0": "person", "p1": "dave"}, "language": "gremlin-groovy"}

Thanks,

smunx avatar Feb 07 '16 07:02 smunx

Hi there,

There is a bug in the _divide_elements function. Note that properties is always set to {}. I fixed it as follows.

    try:
         properties = arg[3]
    except IndexError:
        properties = {}

adriagascon avatar Apr 17 '16 22:04 adriagascon

Sorry somehow I missed this issue when it was first open. @adriagascon would you like to make a PR to fix this issue (with a test)?

davebshow avatar Apr 20 '16 14:04 davebshow