Search code examples
javagremlintinkerpop

Tinkerpop vertex property single cardinality is not working


When creating a vertex i explicitly mentioned Cardinality as single still its taking list, not able figure out why.

wg.addV("label")
.property(VertexProperty.Cardinality.single,"name", "testname").next();

In the above code even after mentioning single it is storing as list.

gremlin server and java driver both use 3.7.2 version.

UPDATE:

Sorry my bad its working got confused by valueMap(true) output where its returning as array for all the fields

g.V(1).valueMap(true).next();

returns

name=[peter], email=[dummy]

So i thought its is storing as list but fixed when used

g.V(1).valueMap(true).by(unfold()).next();

returns

name=peter, email=dummy

Solution

  • I just attempted this in Gremlin Console 3.7.2 with TinkerGraph and it seems to be working as expected:

    gremlin> g.addV('test').property(single,'name','John')
    ==>v[0]
    gremlin> g.V(0L).values('name')
    ==>John
    gremlin> g.V(0L).property(single,'name','Jane')
    ==>v[0]
    gremlin> g.V(0L).values('name')
    ==>Jane
    

    Can you provide further details as to where you're seeing multiple values for the given property?