addV with existing ID doesn't throw error

I noticed when I call addV(newLabel) with an existing ID but a different label, it will add the newLabel and the new properties defined to the existing vertex. This is verrrry undesirable behavior, I would need to it throw a constrain violation. Any thoughts?
Solution:
This works on Neptune b/c of the support for multiple labels. :/
Jump to solution
11 Replies
spmallette
spmallette2y ago
what graph system are you finding this happening with? i would expect the following on any graph:
gremlin> g.addV('new').property(id, 1).property('name','stephen')
Vertex with id already exists: 1
Type ':help' or ':h' for help.
Display stack trace? [yN]
gremlin> g.addV('new').property(id, 1).property('name','stephen')
Vertex with id already exists: 1
Type ':help' or ':h' for help.
Display stack trace? [yN]
i think i recall you were using Neptune - is that right?
Solution
triggan
triggan2y ago
This works on Neptune b/c of the support for multiple labels. :/
spmallette
spmallette2y ago
interesting. i knew Neptune had multi-labels but wouldn't have expected addV() to trigger the multiple labels no workarounds? i guess you'd just have to always validate with fold()/coalesce()/unfold()?
triggan
triggan2y ago
Yes, or use mergeV() once it is supported.
edolivares
edolivares2y ago
Yea this was my problem the other day haha. I wrote a bunch of code that consolidates messy gremlin, locally against the gremlin-server @ 3.6.0 only to realize it’ll have to get stashed until Neptune supports that version
spmallette
spmallette2y ago
so you were trying out the new mergeV() and mergeE() steps?
kyano_k
kyano_kOP2y ago
Hmmm ok Thanks
edolivares
edolivares2y ago
Yes, I was trying it out locally against docker gremlin-server but, I’ll come back to it once gremlin 3.6.0 is supported by Neptune
spmallette
spmallette2y ago
do you happen to have any feedback/thoughts on the API that those new steps offer?
edolivares
edolivares2y ago
I think they’re great you all are amazing! I’d need to look at the internals I wasn’t sure if it is actually calling coalesce or if there is some more complicated conditional logic in there under the hood but, the abstraction is nice and intuitive and it does what I would expect.
spmallette
spmallette2y ago
it is not calling coalesce() it is a brand new natively executed step
Want results from more Discord servers?
Add your server