diff --git a/cql3/expr/expression.cc b/cql3/expr/expression.cc index 78af9f0ad6..27a8d1d132 100644 --- a/cql3/expr/expression.cc +++ b/cql3/expr/expression.cc @@ -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::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::max()) { // TODO: Behaviour copied from maps::delayed_value::bind(), but this seems incorrect // The original reasoning is: