schema_extensions: Add an option to string method
Allow an extension to describe itself as the CQL property
string that created it (and is serialized to schema tables)
Only paxos extension requires override.
(cherry picked from commit d27620e146)
This commit is contained in:
@@ -55,6 +55,10 @@ public:
|
||||
return ser::serialize_to_buffer<bytes>(_paxos_gc_sec);
|
||||
}
|
||||
|
||||
std::string options_to_string() const override {
|
||||
return std::to_string(_paxos_gc_sec);
|
||||
}
|
||||
|
||||
static int32_t deserialize(const bytes_view& buffer) {
|
||||
return ser::deserialize_from_buffer(buffer, boost::type<int32_t>());
|
||||
}
|
||||
|
||||
@@ -768,6 +768,16 @@ static std::ostream& map_as_cql_param(std::ostream& os, const std::map<sstring,
|
||||
return os;
|
||||
}
|
||||
|
||||
// default impl assumes options are in a map.
|
||||
// implementations should override if not
|
||||
std::string schema_extension::options_to_string() const {
|
||||
std::ostringstream ss;
|
||||
ss << '{';
|
||||
map_as_cql_param(ss, ser::deserialize_from_buffer(serialize(), boost::type<default_map_type>(), 0));
|
||||
ss << '}';
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
static std::ostream& column_definition_as_cql_key(std::ostream& os, const column_definition & cd) {
|
||||
os << cd.name_as_cql_string();
|
||||
os << " " << cd.type->cql3_type_name();
|
||||
|
||||
@@ -551,6 +551,10 @@ public:
|
||||
virtual bool is_placeholder() const {
|
||||
return false;
|
||||
}
|
||||
using default_map_type = std::map<sstring, sstring>;
|
||||
// default impl assumes options are in a map.
|
||||
// implementations should override if not
|
||||
virtual std::string options_to_string() const;
|
||||
};
|
||||
|
||||
struct schema_static_props {
|
||||
|
||||
Reference in New Issue
Block a user