1
0
Fork 0

do not allow edge definitions with empty from or to arrays, added als… (#8198)

This commit is contained in:
Heiko 2019-02-20 18:32:33 +01:00 committed by Jan
parent 924115a5d2
commit 4557dfc0d5
2 changed files with 33 additions and 0 deletions

View File

@ -381,6 +381,12 @@ ResultT<EdgeDefinition> EdgeDefinition::createFromVelocypack(VPackSlice edgeDefi
toSet.emplace(it.copyString());
}
// We do not allow creating an edge definition with either an empty from
// or an empty to set
if (fromSet.size() == 0 || toSet.size() == 0) {
return Result(TRI_ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION);
}
return EdgeDefinition{collection, std::move(fromSet), std::move(toSet)};
}

View File

@ -521,6 +521,33 @@ function GeneralGraphCreationSuite() {
assertEqual(g.__edgeDefinitions, []);
},
test_create_WithEmpty_from_to_EdgeDefiniton : function () {
if (db._collection("_graphs").exists(gn)) {
db._collection("_graphs").remove(gn);
}
// EdgeDefinition with empty from and to array
var edgeDef = graph._edgeDefinitions({
"collection": "IhaveNoFromsOrTos",
"from": [],
"to": []
});
try {
graph._create(
gn,
edgeDef,
[],
{
numberOfShards: 4,
smartGraphAttribute: "smart"
}
);
} catch (err) {
assertEqual(err.errorMessage, ERRORS.ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION.message);
}
},
test_create_WithOut_Name : function () {
if (db._collection("_graphs").exists(gn)) {
db._collection("_graphs").remove(gn);