2012-06-07 18:45:06 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-16 05:40:17 +00:00
|
|
|
#include <common/MetrikaTypes.h>
|
2017-02-02 22:08:19 +00:00
|
|
|
#include <common/LocalDate.h>
|
|
|
|
#include <common/LocalDateTime.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Field.h>
|
2017-02-02 22:08:19 +00:00
|
|
|
#include <mysqlxx/Null.h>
|
2012-06-07 18:45:06 +00:00
|
|
|
|
|
|
|
|
2017-04-16 05:40:17 +00:00
|
|
|
/// This is for Yandex.Metrica code.
|
|
|
|
|
|
|
|
|
2012-06-07 18:45:06 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// Перевести что угодно в Field.
|
|
|
|
template <typename T>
|
|
|
|
inline Field toField(const T & x)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
return Field(typename NearestFieldType<T>::Type(x));
|
2012-06-07 18:45:06 +00:00
|
|
|
}
|
|
|
|
|
2016-02-03 01:17:58 +00:00
|
|
|
inline Field toField(const LocalDate & x)
|
2012-06-07 18:45:06 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
return toField(static_cast<UInt16>(x.getDayNum()));
|
2012-06-07 18:45:06 +00:00
|
|
|
}
|
|
|
|
|
2016-02-03 01:17:58 +00:00
|
|
|
inline Field toField(const LocalDateTime & x)
|
2012-06-07 18:45:06 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
return toField(static_cast<UInt32>(static_cast<time_t>(x)));
|
2012-06-07 18:45:06 +00:00
|
|
|
}
|
|
|
|
|
2013-08-11 03:40:14 +00:00
|
|
|
inline Field toField(const VisitID_t & x)
|
2012-06-07 18:45:06 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
return toField(static_cast<UInt64>(x));
|
2012-06-07 18:45:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|