addV() returns wrong vertex ID
Expected behavior 期望表现
Using JavaScript Gremlin client, I run a simple addVertex query:
const test = await g.addV('Test')
.property('foo', 123)
.property('bar', 456)
.next();
console.log(test.value.id);
I expect the returned ID to be the same as the vertex ID.
Actual behavior 实际表现
The returned ID is different from the actual ID of the vertex: Returned: 259663873303379970 Actual: 259663873303379968
Steps to reproduce the problem 复现步骤
Run the above query.
Schema(VertexLabel, EdgeLabel, IndexLabel) 元数据结构
graph.schema().propertyKey('foo').asInt().ifNotExist().create()
graph.schema().propertyKey('bar').asInt().ifNotExist().create()
graph.schema().vertexLabel('Test').properties('foo', 'bar').ifNotExist().create()
Specifications of environment 环境信息
- hugegraph version: v0.10.4
- operating system: Ubuntu 18.04.3 LTS
- hugegraph backend: RocksDB
The root cause is that javascript does not support long variables.
If you have to use javascript, you can use the primary key id or a custom id (non-long). If you can try other ways, hugegraph-client or hugegraph-studio is an alternative. The hugegraph-client is a java driver, which supports long type. The hugegraph-studio is a front-end display platform, we convert long to string when returning it to the front end.
I cannot use custom or primary key IDs in my project. I also find it strange that the root cause is javascript support for long, as I do get a "long" number, just not the correct one.
However, I figured out that setting snowflake.force_string=true in hugegraph.properties does convert all IDs to strings, and it is now working as expected.
Would be great if you could also support UUID and not just long IDs.
Yeap! The config option snowflake.force_string=true will convert all id to string.
HugeGraph support UUID, but need use customizedUUID() that you may cannot use it.
I mean that UUIDs will be automatically manages, same as long, but with UUID. something like: gremlin.tinkergraph.vertexIdManager=UUID