alternator: add support for DeleteRequest in BatchWriteItem

Signed-off-by: Nadav Har'El <nyh@scylladb.com>
This commit is contained in:
Nadav Har'El
2019-07-01 15:24:50 +03:00
parent 83b91d4b49
commit a0fffcebde
2 changed files with 4 additions and 6 deletions

View File

@@ -43,7 +43,6 @@ def test_batch_write_hash_only(test_table_s):
# Test batch delete operation (DeleteRequest): We create a bunch of items, and
# then delete them all.
@pytest.mark.xfail(reason="BatchWriteItem does not yet support DeleteRequest")
def test_batch_write_delete(test_table_s):
items = [{'p': random_string(), 'val': random_string()} for i in range(10)]
with test_table_s.batch_writer() as batch:
@@ -59,7 +58,6 @@ def test_batch_write_delete(test_table_s):
assert not 'Item' in test_table_s.get_item(Key={'p': item['p']}, ConsistentRead=True)
# Test the same batch including both writes and delete. Should be fine.
@pytest.mark.xfail(reason="BatchWriteItem does not yet support DeleteRequest")
def test_batch_write_and_delete(test_table_s):
p1 = random_string()
p2 = random_string()
@@ -82,7 +80,7 @@ def test_batch_write_duplicate_write(test_table_s):
batch.put_item({'p': p})
batch.put_item({'p': p})
@pytest.mark.xfail(reason="BatchWriteItem does not yet support DeleteRequest")
@pytest.mark.xfail(reason="BatchWriteItem does not yet check for duplicates")
def test_batch_write_duplicate_delete(test_table_s):
p = random_string()
with pytest.raises(ClientError, match='ValidationException.*duplicates'):
@@ -90,7 +88,7 @@ def test_batch_write_duplicate_delete(test_table_s):
batch.delete_item(Key={'p': p})
batch.delete_item(Key={'p': p})
@pytest.mark.xfail(reason="BatchWriteItem does not yet support DeleteRequest")
@pytest.mark.xfail(reason="BatchWriteItem does not yet check for duplicates")
def test_batch_write_duplicate_write_and_delete(test_table_s):
p = random_string()
with pytest.raises(ClientError, match='ValidationException.*duplicates'):

View File

@@ -353,8 +353,8 @@ future<json::json_return_type> executor::batch_write_item(std::string content) {
const Json::Value& item = put_request["Item"];
mutations.push_back(make_item_mutation(item, schema));
} else if (r.key() == "DeleteRequest") {
// FIXME:
throw api_error("ValidationException", "BatchWriteItem doesn't support DeleteRequest yet");
const Json::Value& key = (*r)["Key"];
mutations.push_back(make_delete_item_mutation(key, schema));
} else {
throw api_error("ValidationException", format("Unknown BatchWriteItem request type: {}", r.key()));
}