cql3: Fix maps::setter_by_key for unset values
Unset values for key and value were not handled. Handle them in a manner matching Cassandra. This fixes all cases in testMapWithUnsetValues, so re-enable it (and fix a comment typo in it). Signed-off-by: Dejan Mircevski <dejan@scylladb.com>
This commit is contained in:
committed by
Pekka Enberg
parent
4515a49d4d
commit
9eed26ca3d
@@ -302,6 +302,12 @@ maps::setter_by_key::execute(mutation& m, const clustering_key_prefix& prefix, c
|
||||
assert(column.type->is_multi_cell()); // "Attempted to set a value for a single key on a frozen map"m
|
||||
auto key = _k->bind_and_get(params._options);
|
||||
auto value = _t->bind_and_get(params._options);
|
||||
if (value.is_unset_value()) {
|
||||
return;
|
||||
}
|
||||
if (key.is_unset_value() || value.is_unset_value()) {
|
||||
throw invalid_request_exception("Invalid unset map key");
|
||||
}
|
||||
if (!key) {
|
||||
throw invalid_request_exception("Invalid null map key");
|
||||
}
|
||||
|
||||
@@ -274,7 +274,6 @@ def testLists(cql, test_keyspace):
|
||||
execute(cql, table, "UPDATE %s SET l = l - ? WHERE k=0", ["v1", "v2"])
|
||||
assert_rows(execute(cql, table, "SELECT l FROM %s WHERE k = 0"), [None]);
|
||||
|
||||
@pytest.mark.xfail(reason="Cassandra 2.2.0's 'unset' values not yet supported. Issue #7740")
|
||||
def testMapWithUnsetValues(cql, test_keyspace):
|
||||
with create_table(cql, test_keyspace, "(k int PRIMARY KEY, m map<text, text>)") as table:
|
||||
# set up
|
||||
@@ -285,7 +284,7 @@ def testMapWithUnsetValues(cql, test_keyspace):
|
||||
# test putting an unset map, should not delete the contents
|
||||
execute(cql, table, "INSERT INTO %s (k, m) VALUES (10, ?)", UNSET_VALUE)
|
||||
assert_rows(execute(cql, table, "SELECT m FROM %s WHERE k = 10"), [m])
|
||||
# test unset variables in a map update operaiotn, should not delete the contents
|
||||
# test unset variables in a map update operation, should not delete the contents
|
||||
execute(cql, table, "UPDATE %s SET m['k'] = ? WHERE k = 10", UNSET_VALUE)
|
||||
assert_rows(execute(cql, table, "SELECT m FROM %s WHERE k = 10"), [m])
|
||||
assert_invalid_message(cql, table, "Invalid unset map key", "UPDATE %s SET m[?] = 'foo' WHERE k = 10", UNSET_VALUE)
|
||||
|
||||
Reference in New Issue
Block a user