mirror of https://gitee.com/bigwinds/arangodb
do not allow edge definitions with empty from or to arrays, added als… (#8198)
This commit is contained in:
parent
924115a5d2
commit
4557dfc0d5
|
@ -381,6 +381,12 @@ ResultT<EdgeDefinition> EdgeDefinition::createFromVelocypack(VPackSlice edgeDefi
|
||||||
toSet.emplace(it.copyString());
|
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)};
|
return EdgeDefinition{collection, std::move(fromSet), std::move(toSet)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -521,6 +521,33 @@ function GeneralGraphCreationSuite() {
|
||||||
assertEqual(g.__edgeDefinitions, []);
|
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 () {
|
test_create_WithOut_Name : function () {
|
||||||
if (db._collection("_graphs").exists(gn)) {
|
if (db._collection("_graphs").exists(gn)) {
|
||||||
db._collection("_graphs").remove(gn);
|
db._collection("_graphs").remove(gn);
|
||||||
|
|
Loading…
Reference in New Issue