alternator: throw on unsupported expressions

When an unsupported expression parameter is encountered -
KeyConditionExpression, ConditionExpression or FilterExpression
are such - alternator will return an error instead of ignoring
the parameter.
This commit is contained in:
Piotr Sarna
2019-09-02 12:18:19 +02:00
committed by Avi Kivity
parent 811df711fb
commit 3fae8239fa

View File

@@ -597,6 +597,10 @@ future<json::json_return_type> executor::put_item(client_state& client_state, st
schema_ptr schema = get_table(_proxy, update_info);
tracing::add_table_name(client_state.get_trace_state(), schema->ks_name(), schema->cf_name());
if (rjson::find(update_info, "ConditionExpression")) {
throw api_error("ValidationException", "ConditionExpression is not yet implemented in alternator");
}
const rjson::value& item = update_info["Item"];
mutation m = make_item_mutation(item, schema);
@@ -636,6 +640,10 @@ future<json::json_return_type> executor::delete_item(client_state& client_state,
schema_ptr schema = get_table(_proxy, update_info);
tracing::add_table_name(client_state.get_trace_state(), schema->ks_name(), schema->cf_name());
if (rjson::find(update_info, "ConditionExpression")) {
throw api_error("ValidationException", "ConditionExpression is not yet implemented in alternator");
}
const rjson::value& key = update_info["Key"];
mutation m = make_delete_item_mutation(key, schema);
@@ -1264,6 +1272,10 @@ future<json::json_return_type> executor::update_item(client_state& client_state,
schema_ptr schema = get_table(_proxy, update_info);
tracing::add_table_name(client_state.get_trace_state(), schema->ks_name(), schema->cf_name());
if (rjson::find(update_info, "ConditionExpression")) {
throw api_error("ValidationException", "ConditionExpression is not yet implemented in alternator");
}
if (!update_info.HasMember("Key")) {
throw api_error("ValidationException", "UpdateItem requires a Key parameter");
}
@@ -1756,6 +1768,10 @@ future<json::json_return_type> executor::scan(client_state& client_state, std::s
schema_ptr schema = get_table_or_view(_proxy, request_info);
if (rjson::find(request_info, "FilterExpression")) {
throw api_error("ValidationException", "FilterExpression is not yet implemented in alternator");
}
rjson::value* exclusive_start_key = rjson::find(request_info, "ExclusiveStartKey");
//FIXME(sarna): ScanFilter is deprecated in favor of FilterExpression
rjson::value* scan_filter = rjson::find(request_info, "ScanFilter");
@@ -1918,6 +1934,13 @@ future<json::json_return_type> executor::query(client_state& client_state, std::
throw api_error("ValidationException", "Limit must be greater than 0");
}
if (rjson::find(request_info, "KeyConditionExpression")) {
throw api_error("ValidationException", "KeyConditionExpression is not yet implemented in alternator");
}
if (rjson::find(request_info, "FilterExpression")) {
throw api_error("ValidationException", "FilterExpression is not yet implemented in alternator");
}
//FIXME(sarna): KeyConditions are deprecated in favor of KeyConditionExpression
rjson::value& conditions = rjson::get(request_info, "KeyConditions");
//FIXME(sarna): QueryFilter is deprecated in favor of FilterExpression