mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 13:42:02 +00:00
39 lines
701 B
C++
39 lines
701 B
C++
#pragma once
|
|
|
|
#include <common/MetrikaTypes.h>
|
|
#include <common/LocalDate.h>
|
|
#include <common/LocalDateTime.h>
|
|
#include <Core/Field.h>
|
|
#include <mysqlxx/Null.h>
|
|
|
|
|
|
/// This is for Yandex.Metrica code.
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/// Перевести что угодно в Field.
|
|
template <typename T>
|
|
inline Field toField(const T & x)
|
|
{
|
|
return Field(typename NearestFieldType<T>::Type(x));
|
|
}
|
|
|
|
inline Field toField(const LocalDate & x)
|
|
{
|
|
return toField(static_cast<UInt16>(x.getDayNum()));
|
|
}
|
|
|
|
inline Field toField(const LocalDateTime & x)
|
|
{
|
|
return toField(static_cast<UInt32>(static_cast<time_t>(x)));
|
|
}
|
|
|
|
inline Field toField(const VisitID_t & x)
|
|
{
|
|
return toField(static_cast<UInt64>(x));
|
|
}
|
|
|
|
}
|