cql3: expr: do not allow unset values inside collections

Semantic of unset values inside collections is undefined.
Previous behavior of transforming list with unset value into unset value
was removed, because I couldn't find a reason for its existence.
This commit is contained in:
Michał Sala
2022-04-28 19:23:58 +02:00
parent 4766e25d6e
commit 69bc60ef24

View File

@@ -1820,6 +1820,10 @@ static constant evaluate_list(const collection_constructor& collection,
for (const expression& element : collection.elements) {
constant evaluated_element = evaluate(element, options);
if (evaluated_element.is_unset_value()) {
throw exceptions::invalid_request_exception("unset value is not supported inside collections");
}
if (evaluated_element.is_null()) {
if (skip_null) {
continue;
@@ -1828,10 +1832,6 @@ static constant evaluate_list(const collection_constructor& collection,
throw exceptions::invalid_request_exception("null is not supported inside collections");
}
if (evaluated_element.is_unset_value()) {
return constant::make_unset_value(collection.type);
}
evaluated_elements.emplace_back(std::move(evaluated_element).value.to_managed_bytes());
}
@@ -1851,7 +1851,7 @@ static constant evaluate_set(const collection_constructor& collection, const que
}
if (evaluated_element.is_unset_value()) {
return constant::make_unset_value(collection.type);
throw exceptions::invalid_request_exception("unset value is not supported inside collections");
}
if (evaluated_element.view().size_bytes() > std::numeric_limits<uint16_t>::max()) {
@@ -1884,14 +1884,10 @@ static constant evaluate_map(const collection_constructor& collection, const que
throw exceptions::invalid_request_exception("null is not supported inside collections");
}
if (key.is_unset_value()) {
if (key.is_unset_value() || value.is_unset_value()) {
throw exceptions::invalid_request_exception("unset value is not supported inside collections");
}
if (value.is_unset_value()) {
return constant::make_unset_value(collection.type);
}
if (key.view().size_bytes() > std::numeric_limits<uint16_t>::max()) {
// TODO: Behaviour copied from maps::delayed_value::bind(), but this seems incorrect
// The original reasoning is: