diff --git a/cql3/restrictions/restrictions.hh b/cql3/restrictions/restrictions.hh index 111e182f6e..886ede07c3 100644 --- a/cql3/restrictions/restrictions.hh +++ b/cql3/restrictions/restrictions.hh @@ -68,6 +68,10 @@ public: virtual std::vector values(const query_options& options) const = 0; + virtual bytes_opt value_for(const column_definition& cdef, const query_options& options) const { + throw exceptions::invalid_request_exception("Single value can be obtained from single-column restrictions only"); + } + /** * Returns true if one of the restrictions use the specified function. * diff --git a/cql3/restrictions/single_column_primary_key_restrictions.hh b/cql3/restrictions/single_column_primary_key_restrictions.hh index d310f05211..5f6655ab4e 100644 --- a/cql3/restrictions/single_column_primary_key_restrictions.hh +++ b/cql3/restrictions/single_column_primary_key_restrictions.hh @@ -310,6 +310,11 @@ public: } return res; } + + virtual bytes_opt value_for(const column_definition& cdef, const query_options& options) const override { + return _restrictions->value_for(cdef, options); + } + std::vector bounds(statements::bound b, const query_options& options) const override { // TODO: if this proved to be required. fail(unimplemented::cause::LEGACY_COMPOSITE_KEYS); // not 100% correct... diff --git a/cql3/restrictions/single_column_restrictions.hh b/cql3/restrictions/single_column_restrictions.hh index 6408d53fee..63a97feb06 100644 --- a/cql3/restrictions/single_column_restrictions.hh +++ b/cql3/restrictions/single_column_restrictions.hh @@ -111,6 +111,11 @@ public: return r; } + virtual bytes_opt value_for(const column_definition& cdef, const query_options& options) const override { + auto it = _restrictions.find(std::addressof(cdef)); + return (it != _restrictions.end()) ? it->second->value(options) : bytes_opt{}; + } + /** * Returns the restriction associated to the specified column. * diff --git a/cql3/restrictions/statement_restrictions.cc b/cql3/restrictions/statement_restrictions.cc index 8772bfc028..2ced16c4bf 100644 --- a/cql3/restrictions/statement_restrictions.cc +++ b/cql3/restrictions/statement_restrictions.cc @@ -72,6 +72,9 @@ public: // throw? should not reach? return {}; } + bytes_opt value_for(const column_definition& cdef, const query_options& options) const override { + return {}; + } std::vector values_as_keys(const query_options& options) const override { // throw? should not reach? return {};