Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix allowed append vl pk or el sk as nullable props #1406

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,15 @@ private void checkNullableKeys(Action action) {
"must belong to the origin/new properties: %s/%s ",
this.nullableKeys, originProps, appendProps);

E.checkArgument(!CollectionUtil.hasIntersection(this.sortKeys,
List<String> sortKeys = edgeLabel == null ?
this.sortKeys :
this.graph()
.mapPkId2Name(edgeLabel.sortKeys());
E.checkArgument(!CollectionUtil.hasIntersection(sortKeys,
this.nullableKeys),
"The nullableKeys: %s are not allowed to " +
"belong to sortKeys: %s of edge label '%s'",
this.nullableKeys, this.sortKeys, this.name);
this.nullableKeys, sortKeys, this.name);

if (action == Action.APPEND) {
Collection<String> newAddedProps = CollectionUtils.subtract(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,15 @@ private void checkNullableKeys(Action action) {
"must belong to the origin/new properties: %s/%s",
this.nullableKeys, originProps, appendProps);

E.checkArgument(!CollectionUtil.hasIntersection(this.primaryKeys,
List<String> primaryKeys = vertexLabel == null ?
this.primaryKeys :
this.graph()
.mapPkId2Name(vertexLabel.primaryKeys());
E.checkArgument(!CollectionUtil.hasIntersection(primaryKeys,
this.nullableKeys),
"The nullableKeys: %s are not allowed to " +
"belong to primaryKeys: %s of vertex label '%s'",
this.nullableKeys, this.primaryKeys, this.name);
this.nullableKeys, primaryKeys, this.name);

if (action == Action.APPEND) {
Collection<String> newAddedProps = CollectionUtils.subtract(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,31 @@ public void testAppendEdgeLabelWithNonNullProperties() {

}

@Test
public void testAppendEdgeLabelWithSkAsNullableProperties() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person")
.properties("name", "age", "city")
.primaryKeys("name")
.create();
schema.vertexLabel("book").properties("id", "name")
.primaryKeys("id").create();
schema.edgeLabel("look")
.properties("time")
.link("person", "book")
.multiTimes().sortKeys("time")
.create();

Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.edgeLabel("look")
.properties("time", "weight")
.nullableKeys("time", "weight")
.append();
});

}

@Test
public void testRemoveEdgeLabel() {
super.initPropertyKeys();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,23 @@ public void testAppendVertexLabelWithNonNullProperties() {
});
}

@Test
public void testAppendVertexLabelWithPkAsNullableProperties() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();

schema.vertexLabel("person")
.properties("name", "age")
.primaryKeys("name")
.create();
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.vertexLabel("person")
.properties("name", "city")
.nullableKeys("name", "city")
.append();
});
}

@Test
public void testRemoveVertexLabel() {
super.initPropertyKeys();
Expand Down