cql3: add type_parser::parse() method taking user_types_metadata
In a future patch, we don't have access to a `user_types_storage` while we want to parse a type, but we do have access to a `user_types_metadata`, which is enough to parse the type. We add a variant of the `type_parser::parse()` that takes a `user_types_metadata` instead of a `user_types_storage` to be able to parse a type also in the described context.
This commit is contained in:
@@ -24,7 +24,7 @@ static ::shared_ptr<cql3::cql3_type::raw> parse_raw(const sstring& str) {
|
||||
});
|
||||
}
|
||||
|
||||
data_type db::cql_type_parser::parse(const sstring& keyspace, const sstring& str, const data_dictionary::user_types_storage& uts) {
|
||||
data_type db::cql_type_parser::parse(const sstring& keyspace, const sstring& str, const data_dictionary::user_types_metadata& utm) {
|
||||
static const thread_local std::unordered_map<sstring, cql3::cql3_type> native_types = []{
|
||||
std::unordered_map<sstring, cql3::cql3_type> res;
|
||||
for (auto& nt : cql3::cql3_type::values()) {
|
||||
@@ -39,7 +39,11 @@ data_type db::cql_type_parser::parse(const sstring& keyspace, const sstring& str
|
||||
}
|
||||
|
||||
auto raw = parse_raw(str);
|
||||
return raw->prepare_internal(keyspace, uts.get(keyspace)).get_type();
|
||||
return raw->prepare_internal(keyspace, utm).get_type();
|
||||
}
|
||||
|
||||
data_type db::cql_type_parser::parse(const sstring& keyspace, const sstring& str, const data_dictionary::user_types_storage& uts) {
|
||||
return parse(keyspace, str, uts.get(keyspace));
|
||||
}
|
||||
|
||||
class db::cql_type_parser::raw_builder::impl {
|
||||
|
||||
@@ -22,11 +22,13 @@ class types_metadata;
|
||||
namespace data_dictionary {
|
||||
class keyspace_metadata;
|
||||
class user_types_storage;
|
||||
class user_types_metadata;
|
||||
}
|
||||
|
||||
namespace db {
|
||||
namespace cql_type_parser {
|
||||
|
||||
data_type parse(const sstring& keyspace, const sstring& type, const data_dictionary::user_types_metadata& utm);
|
||||
data_type parse(const sstring& keyspace, const sstring& type, const data_dictionary::user_types_storage& uts);
|
||||
|
||||
class raw_builder {
|
||||
|
||||
Reference in New Issue
Block a user