apache / apache/hugegraph

[Bug] Add primary key with same value not throwing error

Open
#2,742 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
3.2k
Forks
636
Avg merge
3d 11h
Merged PRs (30d)
14

Description

### Bug Type (问题类型)

None

### Before submit

- [x] 我已经确认现有的 [Issues](https://github.com/apache/hugegraph/issues) 与 [FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)

### Environment (环境信息)

- Server Version: Build from source code
- Backend: Memory
- OS: Ubuntu
- Data Size: 2 vertices

### Expected & Actual behavior (期望与实际表现)

If primary key is about having a unique value then following test case must throw some exception but its passing. Why its silently rejecting second vertex? It should have some config that let schema decide that in case of duplicate should it be ignored or throw exception.

```
@Test
public void testPrimaryKey() {

HugeGraph graph = graph();
SchemaManager schema = graph.schema();

schema.propertyKey("prop").asInt().create();
schema.propertyKey("id").asInt().create();

schema.vertexLabel("user").primaryKeys("prop")
.properties("id", "prop").create();

graph.tx().commit();
graph().addVertex(T.label, "user", "id", 1, "prop", 10);
graph.tx().commit();
graph().addVertex(T.label, "user", "id", 1, "prop", 10);
graph.tx().commit();

List persons = graph().traversal().V()
.hasLabel("user").toList();
Assert.assertEquals(1, persons.size());
}
```

### Vertex/Edge example (问题点 / 边数据举例)

```javascript

```

### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

```javascript

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.