8000 Bug fix 3.5/fix view creation errors by KVS85 · Pull Request #9599 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Bug fix 3.5/fix view creation errors #9599

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

Merged
merged 2 commits into from
Jul 29, 2019
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
25 changes: 15 additions & 10 deletions arangod/RestHandler/RestViewHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,25 +166,30 @@ 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;
}

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;
}
Expand Down
4 changes: 2 additions & 2 deletions arangod/RestServer/ViewTypesFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand All @@ -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());
}
};
Expand Down
0