mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 09:22:05 +00:00
Merge pull request #72659 from ClickHouse/imp-safeget
Safer Field::safeGet?
This commit is contained in:
commit
46f5f79ab5
@ -479,12 +479,20 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T> auto & safeGet() const
|
||||
template <typename T> const auto & safeGet() const &
|
||||
{
|
||||
return const_cast<Field *>(this)->safeGet<T>();
|
||||
}
|
||||
template <typename T> auto safeGet() const &&
|
||||
{
|
||||
return std::move(const_cast<Field *>(this)->safeGet<T>());
|
||||
}
|
||||
|
||||
template <typename T> auto & safeGet();
|
||||
template <typename T> auto & safeGet() &;
|
||||
template <typename T> auto safeGet() &&
|
||||
{
|
||||
return std::move(safeGet<T>());
|
||||
}
|
||||
|
||||
bool operator< (const Field & rhs) const
|
||||
{
|
||||
@ -880,7 +888,7 @@ constexpr bool isInt64OrUInt64orBoolFieldType(Field::Types::Which t)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto & Field::safeGet()
|
||||
auto & Field::safeGet() &
|
||||
{
|
||||
const Types::Which target = TypeToEnum<NearestFieldType<std::decay_t<T>>>::value;
|
||||
|
||||
|
@ -398,8 +398,8 @@ ASTPtr parseAdditionalFilterConditionForTable(
|
||||
for (const auto & additional_filter : additional_table_filters)
|
||||
{
|
||||
const auto & tuple = additional_filter.safeGet<const Tuple &>();
|
||||
auto & table = tuple.at(0).safeGet<String>();
|
||||
auto & filter = tuple.at(1).safeGet<String>();
|
||||
const auto & table = tuple.at(0).safeGet<String>();
|
||||
const auto & filter = tuple.at(1).safeGet<String>();
|
||||
|
||||
if (table == target.alias ||
|
||||
(table == target.table && context.getCurrentDatabase() == target.database) ||
|
||||
|
Loading…
Reference in New Issue
Block a user