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