1
0
Fork 0

Put in tests to check for existence of _from and _to in edges.

This commit is contained in:
Max Neunhoeffer 2016-03-08 11:20:52 +01:00
parent fc44d4af6f
commit a9be9b4fdb
2 changed files with 25 additions and 1 deletions

View File

@ -1483,7 +1483,7 @@ static void ModifyVocbaseCol(TRI_voc_document_operation_e operation,
auto workOnOneSearchVal = [&](v8::Local<v8::Value> const searchVal) {
std::string collName;
if (!ExtractDocumentHandle(isolate, searchVal, collName,
updateBuilder, false)) {
updateBuilder, true)) {
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_DOCUMENT_HANDLE_BAD);
}
};

View File

@ -3305,6 +3305,18 @@ int TRI_document_collection_t::insert(Transaction* trx, VPackSlice const* slice,
TRI_doc_mptr_t* mptr,
OperationOptions& options,
bool lock) {
if (_info.type() == TRI_COL_TYPE_EDGE) {
VPackSlice s = slice->get(TRI_VOC_ATTRIBUTE_FROM);
if (!s.isString()) {
return TRI_ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE;
}
s = slice->get(TRI_VOC_ATTRIBUTE_TO);
if (!s.isString()) {
return TRI_ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE;
}
}
TRI_ASSERT(mptr != nullptr);
mptr->setDataPtr(nullptr);
@ -3497,6 +3509,18 @@ int TRI_document_collection_t::replace(Transaction* trx,
OperationOptions& options,
bool lock,
TRI_voc_rid_t& prevRev) {
if (_info.type() == TRI_COL_TYPE_EDGE) {
VPackSlice s = newSlice.get(TRI_VOC_ATTRIBUTE_FROM);
if (!s.isString()) {
return TRI_ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE;
}
s = newSlice.get(TRI_VOC_ATTRIBUTE_TO);
if (!s.isString()) {
return TRI_ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE;
}
}
// initialize the result
TRI_ASSERT(mptr != nullptr);
mptr->setDataPtr(nullptr);