davebshow / gremlinrestclient

http://gremlinrestclient.readthedocs.org/en/latest/
MIT License
18 stars 7 forks source link

Duplicate Vertices created by readme sample code #2

Closed PeterLappo closed 9 years ago

PeterLappo commented 9 years ago

Hi Dave, When I'm running against tinkergraph I get duplicate vertices with the last example when starting with a clean database. See below for code, console output and reply from server using http://localhost:8182/?gremlin=g.V()

Also Id seems to be created as a property, which doesn't look right. Will try sample on titan too and let you know.

Other than than that pretty cool library and better than gremlin console if we can solve the duplicates. Cheers Peter

Code

client = gremlinrestclient.GremlinRestClient()
graph = gremlinrestclient.TinkerGraph()
d = {"name": "dave", "label": "person"}
coll = graph.create(d)
dave, = coll.vertices  # Unpack tuple of length 1
print(dave)
print(coll)
coll = graph.create(
   {"name": "python", "label": "lang"},
   (dave, "LIKES", 0, {'weight': 1}))
print(coll)
resp = client.execute("g.V()")
print(resp)

Console output

Response(status_code=200,
data=[
  {
    u'properties': {
      u'name': [
        {
          u'id': 1,
          u'value': u'dave'
        }
      ]
    },
    u'type': u'vertex',
    u'id': 0,
    u'label': u'person'
  },
  {
    u'properties': {
      u'name': [
        {
          u'id': 3,
          u'value': [
            {
              u'id': 1,
              u'value': u'dave'
            }
          ]
        }
      ]
    },
    u'type': u'vertex',
    u'id': 2,
    u'label': u'person'
  },
  {
    u'properties': {
      u'name': [
        {
          u'id': 5,
          u'value': u'python'
        }
      ]
    },
    u'type': u'vertex',
    u'id': 4,
    u'label': u'lang'
  }
],
message={

},
metadata=u'')

Reply from server

{
  "requestId": "2d571957-c321-408c-b2b1-765c67abf2b1",
  "status": {
    "message": "",
    "code": 200,
    "attributes": {

    }
  },
  "result": {
    "data": [
      {
        "id": 0,
        "label": "person",
        "type": "vertex",
        "properties": {
          "name": [
            {
              "id": 1,
              "value": "dave"
            }
          ]
        }
      },
      {
        "id": 2,
        "label": "person",
        "type": "vertex",
        "properties": {
          "name": [
            {
              "id": 3,
              "value": [
                {
                  "id": 1,
                  "value": "dave"
                }
              ]
            }
          ]
        }
      },
      {
        "id": 4,
        "label": "lang",
        "type": "vertex",
        "properties": {
          "name": [
            {
              "id": 5,
              "value": "python"
            }
          ]
        }
      }
    ],
    "meta": {

    }
  }
}
PeterLappo commented 9 years ago

Works fine with Titan. Perhaps its my tinkergraph setup or just a feature of tinkergraph

davebshow commented 9 years ago

Peter,

Thanks for reporting this. It was definitely a bug that has to do with the fact that Tinkergraph assigns a node id of 0, which caused a truth check to fail.

PeterLappo commented 9 years ago

thanks