Skip to content

Unexpected results when updating property #99

@mbbfyb

Description

@mbbfyb

I am receiving some unexpected results updating a property on a vertex, and wanted to make sure it was not user error.

Here is the output of my python shell

>>> import goblin
>>> import asyncio
>>> from goblin import Goblin
>>>
>>> class Person(goblin.Vertex):
...     car = goblin.Property(goblin.String)
...
>>> async def store_element(app, vertex1):
...     session = await app.session()
...     session.add(vertex1)
...     await session.flush()
...
>>> async def close(app):
...     await app.close()
...
>>> loop = asyncio.get_event_loop()
>>> app = loop.run_until_complete(Goblin.open(loop, hosts=["localhost"]))
>>> app.register(Person)
>>> p1 = Person()
>>> p1.car = "honda"
>>> loop.run_until_complete(store_element(app, p1))
>>> print(p1.car)
honda
>>> p1.car = "toyota"
>>> loop.run_until_complete(store_element(app, p1))
>>> print(p1.car)
['toyota', 'honda']
>>> loop.run_until_complete(close(app))
>>> loop.close()

Notice that instead of overwriting the element, it is appended like an array. I see this behavior using both the regular Property class and VertexProperty class, in which I would expect the behavior to just overwrite the field value. In the gremlin console the particular vertex ends up having 2 fields named car.

gremlin> g.V().has('car').properties()
==>vp[car->toyota]
==>vp[car->honda]

Is this to be expected? I am using Amazon Neptune with the following packages

aiogremlin==3.2.4
goblin==2.0.0
gremlinpython==3.3.1

My suspicion is that somewhere within this function there is something going wrong when doing either the drop iterator or the add iterator that is causing the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions