mirror of https://gitee.com/bigwinds/arangodb
Bug fix 3.5/fix view creation errors (#9599)
* Fix ArangoSearch view creation errors * Fix another error
This commit is contained in:
parent
f995c46b71
commit
40c27d283e
|
@ -166,14 +166,9 @@ void RestViewHandler::createView() {
|
|||
return;
|
||||
}
|
||||
|
||||
auto badParamError = [&]() -> void {
|
||||
generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
|
||||
"expecting body to be of the form {name: <string>, type: "
|
||||
"<string>, properties: <object>}");
|
||||
};
|
||||
|
||||
if (!body.isObject()) {
|
||||
badParamError();
|
||||
generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
|
||||
"request body is not an object");
|
||||
events::CreateView(_vocbase.name(), "", TRI_ERROR_BAD_PARAMETER);
|
||||
return;
|
||||
}
|
||||
|
@ -181,10 +176,20 @@ void RestViewHandler::createView() {
|
|||
auto nameSlice = body.get(StaticStrings::DataSourceName);
|
||||
auto typeSlice = body.get(StaticStrings::DataSourceType);
|
||||
|
||||
if (!nameSlice.isString() || !typeSlice.isString()) {
|
||||
badParamError();
|
||||
if (!nameSlice.isString()) {
|
||||
generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
|
||||
"expecting name parameter to be of the form of \"name: "
|
||||
"<string>\"");
|
||||
events::CreateView(_vocbase.name(), "", TRI_ERROR_BAD_PARAMETER);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!typeSlice.isString()) {
|
||||
generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
|
||||
"expecting type parameter to be of the form of \"type: "
|
||||
"<string>\"");
|
||||
events::CreateView(_vocbase.name(),
|
||||
(nameSlice.isString() ? nameSlice.copyString() : ""),
|
||||
nameSlice.copyString(),
|
||||
TRI_ERROR_BAD_PARAMETER);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ struct InvalidViewFactory : public arangodb::ViewFactory {
|
|||
return arangodb::Result(
|
||||
TRI_ERROR_BAD_PARAMETER,
|
||||
std::string(
|
||||
"failure to create view without a factory for definition: ") +
|
||||
"invalid type provided to create view with definition: ") +
|
||||
definition.toString());
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ struct InvalidViewFactory : public arangodb::ViewFactory {
|
|||
return arangodb::Result(
|
||||
TRI_ERROR_BAD_PARAMETER,
|
||||
std::string(
|
||||
"failure to instantiate view without a factory for definition: ") +
|
||||
"invalid type provided to instantiate view with definition: ") +
|
||||
definition.toString());
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue