mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
Renamed date/date_time to day_point/time_point
This commit is contained in:
parent
5e83929555
commit
84ab264702
@ -28,8 +28,8 @@
|
|||||||
#define SQLPP_COLUMN_TYPES_H
|
#define SQLPP_COLUMN_TYPES_H
|
||||||
|
|
||||||
#include <sqlpp11/boolean.h>
|
#include <sqlpp11/boolean.h>
|
||||||
#include <sqlpp11/date.h>
|
#include <sqlpp11/day_point.h>
|
||||||
#include <sqlpp11/date_time.h>
|
#include <sqlpp11/time_point.h>
|
||||||
#include <sqlpp11/integral.h>
|
#include <sqlpp11/integral.h>
|
||||||
#include <sqlpp11/floating_point.h>
|
#include <sqlpp11/floating_point.h>
|
||||||
#include <sqlpp11/text.h>
|
#include <sqlpp11/text.h>
|
||||||
|
@ -39,8 +39,8 @@ namespace sqlpp
|
|||||||
using mus_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::microseconds>;
|
using mus_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::microseconds>;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct date;
|
struct day_point;
|
||||||
struct date_time;
|
struct time_point;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,11 +24,11 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SQLPP_DATE_H
|
#ifndef SQLPP_DAY_POINT_H
|
||||||
#define SQLPP_DATE_H
|
#define SQLPP_DAY_POINT_H
|
||||||
|
|
||||||
#include <date.h>
|
#include <date.h>
|
||||||
#include <sqlpp11/date_time.h>
|
#include <sqlpp11/time_point.h>
|
||||||
#include <sqlpp11/basic_expression_operators.h>
|
#include <sqlpp11/basic_expression_operators.h>
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
#include <sqlpp11/exception.h>
|
#include <sqlpp11/exception.h>
|
||||||
@ -38,10 +38,10 @@
|
|||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
// date value type
|
// day_point value type
|
||||||
struct date
|
struct day_point
|
||||||
{
|
{
|
||||||
using _traits = make_traits<date, tag::is_value_type>;
|
using _traits = make_traits<day_point, tag::is_value_type>;
|
||||||
using _tag = tag::is_date;
|
using _tag = tag::is_date;
|
||||||
using _cpp_value_type = ::sqlpp::chrono::day_point;
|
using _cpp_value_type = ::sqlpp::chrono::day_point;
|
||||||
|
|
||||||
@ -51,11 +51,11 @@ namespace sqlpp
|
|||||||
using _is_valid_assignment_operand = is_date_t<T>;
|
using _is_valid_assignment_operand = is_date_t<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// date parameter value
|
// day_point parameter value
|
||||||
template <>
|
template <>
|
||||||
struct parameter_value_t<date>
|
struct parameter_value_t<day_point>
|
||||||
{
|
{
|
||||||
using _value_type = date;
|
using _value_type = day_point;
|
||||||
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
||||||
|
|
||||||
parameter_value_t() : _value{}, _is_null(true)
|
parameter_value_t() : _value{}, _is_null(true)
|
||||||
@ -120,28 +120,29 @@ namespace sqlpp
|
|||||||
bool _is_null;
|
bool _is_null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// date expression operators
|
// day_point expression operators
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
struct expression_operators<Base, date> : public basic_expression_operators<Base, date>
|
struct expression_operators<Base, day_point> : public basic_expression_operators<Base, day_point>
|
||||||
{
|
{
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using _is_valid_operand = is_valid_operand<date, T>;
|
using _is_valid_operand = is_valid_operand<day_point, T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// date column operators
|
// day_point column operators
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
struct column_operators<Base, date>
|
struct column_operators<Base, day_point>
|
||||||
{
|
{
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using _is_valid_operand = is_valid_operand<date, T>;
|
using _is_valid_operand = is_valid_operand<day_point, T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// date result field
|
// day_point result field
|
||||||
template <typename Db, typename FieldSpec>
|
template <typename Db, typename FieldSpec>
|
||||||
struct result_field_t<date, Db, FieldSpec> : public result_field_methods_t<result_field_t<date, Db, FieldSpec>>
|
struct result_field_t<day_point, Db, FieldSpec>
|
||||||
|
: public result_field_methods_t<result_field_t<day_point, Db, FieldSpec>>
|
||||||
{
|
{
|
||||||
static_assert(std::is_same<value_type_of<FieldSpec>, date>::value, "field type mismatch");
|
static_assert(std::is_same<value_type_of<FieldSpec>, day_point>::value, "field type mismatch");
|
||||||
using _cpp_value_type = typename sqlpp::date::_cpp_value_type;
|
using _cpp_value_type = typename sqlpp::day_point::_cpp_value_type;
|
||||||
|
|
||||||
result_field_t() : _is_valid(false), _is_null(true), _value{}
|
result_field_t() : _is_valid(false), _is_null(true), _value{}
|
||||||
{
|
{
|
||||||
@ -206,10 +207,10 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Db, typename FieldSpec>
|
template <typename Context, typename Db, typename FieldSpec>
|
||||||
struct serializer_t<Context, result_field_t<date, Db, FieldSpec>>
|
struct serializer_t<Context, result_field_t<day_point, Db, FieldSpec>>
|
||||||
{
|
{
|
||||||
using _serialize_check = consistent_t;
|
using _serialize_check = consistent_t;
|
||||||
using T = result_field_t<date, Db, FieldSpec>;
|
using T = result_field_t<day_point, Db, FieldSpec>;
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
static Context& _(const T& t, Context& context)
|
||||||
{
|
{
|
||||||
@ -227,7 +228,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Db, typename FieldSpec>
|
template <typename Db, typename FieldSpec>
|
||||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<date, Db, FieldSpec>& e)
|
inline std::ostream& operator<<(std::ostream& os, const result_field_t<day_point, Db, FieldSpec>& e)
|
||||||
{
|
{
|
||||||
return serialize(e, os);
|
return serialize(e, os);
|
||||||
}
|
}
|
@ -24,8 +24,8 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SQLPP_DATE_TIME_H
|
#ifndef SQLPP_TIME_POINT_H
|
||||||
#define SQLPP_DATE_TIME_H
|
#define SQLPP_TIME_POINT_H
|
||||||
|
|
||||||
#include <sqlpp11/date_time_fwd.h>
|
#include <sqlpp11/date_time_fwd.h>
|
||||||
#include <sqlpp11/basic_expression_operators.h>
|
#include <sqlpp11/basic_expression_operators.h>
|
||||||
@ -37,10 +37,10 @@
|
|||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
// date_time value type
|
// time_point value type
|
||||||
struct date_time
|
struct time_point
|
||||||
{
|
{
|
||||||
using _traits = make_traits<date_time, tag::is_value_type>;
|
using _traits = make_traits<time_point, tag::is_value_type>;
|
||||||
using _tag = tag::is_date_time;
|
using _tag = tag::is_date_time;
|
||||||
using _cpp_value_type = ::sqlpp::chrono::mus_point;
|
using _cpp_value_type = ::sqlpp::chrono::mus_point;
|
||||||
|
|
||||||
@ -48,11 +48,11 @@ namespace sqlpp
|
|||||||
using _is_valid_operand = is_time_point_t<T>;
|
using _is_valid_operand = is_time_point_t<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// date_time parameter value
|
// time_point parameter value
|
||||||
template <>
|
template <>
|
||||||
struct parameter_value_t<date_time>
|
struct parameter_value_t<time_point>
|
||||||
{
|
{
|
||||||
using _value_type = date_time;
|
using _value_type = time_point;
|
||||||
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
||||||
|
|
||||||
parameter_value_t() : _value{}, _is_null(true)
|
parameter_value_t() : _value{}, _is_null(true)
|
||||||
@ -117,29 +117,29 @@ namespace sqlpp
|
|||||||
bool _is_null;
|
bool _is_null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// date_time expression operators
|
// time_point expression operators
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
struct expression_operators<Base, date_time> : public basic_expression_operators<Base, date_time>
|
struct expression_operators<Base, time_point> : public basic_expression_operators<Base, time_point>
|
||||||
{
|
{
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using _is_valid_operand = is_valid_operand<date_time, T>;
|
using _is_valid_operand = is_valid_operand<time_point, T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// date_time column operators
|
// time_point column operators
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
struct column_operators<Base, date_time>
|
struct column_operators<Base, time_point>
|
||||||
{
|
{
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using _is_valid_operand = is_valid_operand<date_time, T>;
|
using _is_valid_operand = is_valid_operand<time_point, T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// date_time result field
|
// time_point result field
|
||||||
template <typename Db, typename FieldSpec>
|
template <typename Db, typename FieldSpec>
|
||||||
struct result_field_t<date_time, Db, FieldSpec>
|
struct result_field_t<time_point, Db, FieldSpec>
|
||||||
: public result_field_methods_t<result_field_t<date_time, Db, FieldSpec>>
|
: public result_field_methods_t<result_field_t<time_point, Db, FieldSpec>>
|
||||||
{
|
{
|
||||||
static_assert(std::is_same<value_type_of<FieldSpec>, date_time>::value, "field type mismatch");
|
static_assert(std::is_same<value_type_of<FieldSpec>, time_point>::value, "field type mismatch");
|
||||||
using _cpp_value_type = typename date_time::_cpp_value_type;
|
using _cpp_value_type = typename time_point::_cpp_value_type;
|
||||||
|
|
||||||
result_field_t() : _is_valid(false), _is_null(true), _value{}
|
result_field_t() : _is_valid(false), _is_null(true), _value{}
|
||||||
{
|
{
|
||||||
@ -204,10 +204,10 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Db, typename FieldSpec>
|
template <typename Context, typename Db, typename FieldSpec>
|
||||||
struct serializer_t<Context, result_field_t<date_time, Db, FieldSpec>>
|
struct serializer_t<Context, result_field_t<time_point, Db, FieldSpec>>
|
||||||
{
|
{
|
||||||
using _serialize_check = consistent_t;
|
using _serialize_check = consistent_t;
|
||||||
using T = result_field_t<date_time, Db, FieldSpec>;
|
using T = result_field_t<time_point, Db, FieldSpec>;
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
static Context& _(const T& t, Context& context)
|
||||||
{
|
{
|
||||||
@ -227,7 +227,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Db, typename FieldSpec>
|
template <typename Db, typename FieldSpec>
|
||||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<date_time, Db, FieldSpec>& e)
|
inline std::ostream& operator<<(std::ostream& os, const result_field_t<time_point, Db, FieldSpec>& e)
|
||||||
{
|
{
|
||||||
return serialize(e, os);
|
return serialize(e, os);
|
||||||
}
|
}
|
@ -85,27 +85,27 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct date_operand : public alias_operators<date_operand>
|
struct day_point_operand : public alias_operators<day_point_operand>
|
||||||
{
|
{
|
||||||
using _traits = make_traits<date, tag::is_expression, tag::is_wrapped_value>;
|
using _traits = make_traits<day_point, tag::is_expression, tag::is_wrapped_value>;
|
||||||
using _nodes = detail::type_vector<>;
|
using _nodes = detail::type_vector<>;
|
||||||
using _is_aggregate_expression = std::true_type;
|
using _is_aggregate_expression = std::true_type;
|
||||||
|
|
||||||
using _value_t = ::sqlpp::chrono::day_point;
|
using _value_t = ::sqlpp::chrono::day_point;
|
||||||
|
|
||||||
date_operand() : _t{}
|
day_point_operand() : _t{}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
date_operand(_value_t t) : _t(t)
|
day_point_operand(_value_t t) : _t(t)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
date_operand(const date_operand&) = default;
|
day_point_operand(const day_point_operand&) = default;
|
||||||
date_operand(date_operand&&) = default;
|
day_point_operand(day_point_operand&&) = default;
|
||||||
date_operand& operator=(const date_operand&) = default;
|
day_point_operand& operator=(const day_point_operand&) = default;
|
||||||
date_operand& operator=(date_operand&&) = default;
|
day_point_operand& operator=(day_point_operand&&) = default;
|
||||||
~date_operand() = default;
|
~day_point_operand() = default;
|
||||||
|
|
||||||
bool _is_trivial() const
|
bool _is_trivial() const
|
||||||
{
|
{
|
||||||
@ -116,10 +116,10 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, date_operand>
|
struct serializer_t<Context, day_point_operand>
|
||||||
{
|
{
|
||||||
using _serialize_check = consistent_t;
|
using _serialize_check = consistent_t;
|
||||||
using Operand = date_operand;
|
using Operand = day_point_operand;
|
||||||
|
|
||||||
static Context& _(const Operand& t, Context& context)
|
static Context& _(const Operand& t, Context& context)
|
||||||
{
|
{
|
||||||
@ -130,27 +130,27 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Period>
|
template <typename Period>
|
||||||
struct date_time_operand : public alias_operators<date_time_operand<Period>>
|
struct time_point_operand : public alias_operators<time_point_operand<Period>>
|
||||||
{
|
{
|
||||||
using _traits = make_traits<date_time, tag::is_expression, tag::is_wrapped_value>;
|
using _traits = make_traits<time_point, tag::is_expression, tag::is_wrapped_value>;
|
||||||
using _nodes = detail::type_vector<>;
|
using _nodes = detail::type_vector<>;
|
||||||
using _is_aggregate_expression = std::true_type;
|
using _is_aggregate_expression = std::true_type;
|
||||||
|
|
||||||
using _value_t = std::chrono::time_point<std::chrono::system_clock, Period>;
|
using _value_t = std::chrono::time_point<std::chrono::system_clock, Period>;
|
||||||
|
|
||||||
date_time_operand() : _t{}
|
time_point_operand() : _t{}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
date_time_operand(_value_t t) : _t(t)
|
time_point_operand(_value_t t) : _t(t)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
date_time_operand(const date_time_operand&) = default;
|
time_point_operand(const time_point_operand&) = default;
|
||||||
date_time_operand(date_time_operand&&) = default;
|
time_point_operand(time_point_operand&&) = default;
|
||||||
date_time_operand& operator=(const date_time_operand&) = default;
|
time_point_operand& operator=(const time_point_operand&) = default;
|
||||||
date_time_operand& operator=(date_time_operand&&) = default;
|
time_point_operand& operator=(time_point_operand&&) = default;
|
||||||
~date_time_operand() = default;
|
~time_point_operand() = default;
|
||||||
|
|
||||||
bool _is_trivial() const
|
bool _is_trivial() const
|
||||||
{
|
{
|
||||||
@ -161,10 +161,10 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Period>
|
template <typename Context, typename Period>
|
||||||
struct serializer_t<Context, date_time_operand<Period>>
|
struct serializer_t<Context, time_point_operand<Period>>
|
||||||
{
|
{
|
||||||
using _serialize_check = consistent_t;
|
using _serialize_check = consistent_t;
|
||||||
using Operand = date_time_operand<Period>;
|
using Operand = time_point_operand<Period>;
|
||||||
|
|
||||||
static Context& _(const Operand& t, Context& context)
|
static Context& _(const Operand& t, Context& context)
|
||||||
{
|
{
|
||||||
@ -320,13 +320,13 @@ namespace sqlpp
|
|||||||
template <typename Period>
|
template <typename Period>
|
||||||
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, Period>, void>
|
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, Period>, void>
|
||||||
{
|
{
|
||||||
using type = date_time_operand<Period>;
|
using type = time_point_operand<Period>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, sqlpp::chrono::days>, void>
|
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, sqlpp::chrono::days>, void>
|
||||||
{
|
{
|
||||||
using type = date_operand;
|
using type = day_point_operand;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -101,8 +101,8 @@ types = {
|
|||||||
'boolean': 'boolean',
|
'boolean': 'boolean',
|
||||||
'double': 'floating_point',
|
'double': 'floating_point',
|
||||||
'float': 'floating_point',
|
'float': 'floating_point',
|
||||||
'date' : 'date',
|
'date' : 'day_point',
|
||||||
'datetime' : 'date_time',
|
'datetime' : 'time_point',
|
||||||
}
|
}
|
||||||
|
|
||||||
# PROCESS DDL
|
# PROCESS DDL
|
||||||
|
@ -98,49 +98,49 @@ namespace test
|
|||||||
};
|
};
|
||||||
using _traits = sqlpp::make_traits<sqlpp::boolean, sqlpp::tag::can_be_null>;
|
using _traits = sqlpp::make_traits<sqlpp::boolean, sqlpp::tag::can_be_null>;
|
||||||
};
|
};
|
||||||
struct SomeDate
|
struct SomeDayPoint
|
||||||
{
|
{
|
||||||
struct _alias_t
|
struct _alias_t
|
||||||
{
|
{
|
||||||
static constexpr const char _literal[] = "some_date";
|
static constexpr const char _literal[] = "some_day_point";
|
||||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct _member_t
|
struct _member_t
|
||||||
{
|
{
|
||||||
T someDate;
|
T someDayPoint;
|
||||||
T& operator()()
|
T& operator()()
|
||||||
{
|
{
|
||||||
return someDate;
|
return someDayPoint;
|
||||||
}
|
}
|
||||||
const T& operator()() const
|
const T& operator()() const
|
||||||
{
|
{
|
||||||
return someDate;
|
return someDayPoint;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
using _traits = sqlpp::make_traits<sqlpp::date, sqlpp::tag::can_be_null>;
|
using _traits = sqlpp::make_traits<sqlpp::day_point, sqlpp::tag::can_be_null>;
|
||||||
};
|
};
|
||||||
struct SomeDateTime
|
struct SomeTimePoint
|
||||||
{
|
{
|
||||||
struct _alias_t
|
struct _alias_t
|
||||||
{
|
{
|
||||||
static constexpr const char _literal[] = "some_date_time";
|
static constexpr const char _literal[] = "some_time_point";
|
||||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct _member_t
|
struct _member_t
|
||||||
{
|
{
|
||||||
T someDateTime;
|
T someTimePoint;
|
||||||
T& operator()()
|
T& operator()()
|
||||||
{
|
{
|
||||||
return someDateTime;
|
return someTimePoint;
|
||||||
}
|
}
|
||||||
const T& operator()() const
|
const T& operator()() const
|
||||||
{
|
{
|
||||||
return someDateTime;
|
return someTimePoint;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
using _traits = sqlpp::make_traits<sqlpp::date_time, sqlpp::tag::can_be_null>;
|
using _traits = sqlpp::make_traits<sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||||
};
|
};
|
||||||
struct OtherInt
|
struct OtherInt
|
||||||
{
|
{
|
||||||
@ -208,49 +208,49 @@ namespace test
|
|||||||
};
|
};
|
||||||
using _traits = sqlpp::make_traits<sqlpp::boolean, sqlpp::tag::can_be_null>;
|
using _traits = sqlpp::make_traits<sqlpp::boolean, sqlpp::tag::can_be_null>;
|
||||||
};
|
};
|
||||||
struct OtherDate
|
struct OtherDayPoint
|
||||||
{
|
{
|
||||||
struct _alias_t
|
struct _alias_t
|
||||||
{
|
{
|
||||||
static constexpr const char _literal[] = "other_date";
|
static constexpr const char _literal[] = "other_day_point";
|
||||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct _member_t
|
struct _member_t
|
||||||
{
|
{
|
||||||
T otherDate;
|
T otherDayPoint;
|
||||||
T& operator()()
|
T& operator()()
|
||||||
{
|
{
|
||||||
return otherDate;
|
return otherDayPoint;
|
||||||
}
|
}
|
||||||
const T& operator()() const
|
const T& operator()() const
|
||||||
{
|
{
|
||||||
return otherDate;
|
return otherDayPoint;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
using _traits = sqlpp::make_traits<sqlpp::date, sqlpp::tag::can_be_null>;
|
using _traits = sqlpp::make_traits<sqlpp::day_point, sqlpp::tag::can_be_null>;
|
||||||
};
|
};
|
||||||
struct OtherDateTime
|
struct OtherTimePoint
|
||||||
{
|
{
|
||||||
struct _alias_t
|
struct _alias_t
|
||||||
{
|
{
|
||||||
static constexpr const char _literal[] = "other_date_time";
|
static constexpr const char _literal[] = "other_time_point";
|
||||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct _member_t
|
struct _member_t
|
||||||
{
|
{
|
||||||
T otherDateTime;
|
T otherTimePoint;
|
||||||
T& operator()()
|
T& operator()()
|
||||||
{
|
{
|
||||||
return otherDateTime;
|
return otherTimePoint;
|
||||||
}
|
}
|
||||||
const T& operator()() const
|
const T& operator()() const
|
||||||
{
|
{
|
||||||
return otherDateTime;
|
return otherTimePoint;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
using _traits = sqlpp::make_traits<sqlpp::date_time, sqlpp::tag::can_be_null>;
|
using _traits = sqlpp::make_traits<sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,13 +259,13 @@ namespace test
|
|||||||
TabAllTypes_::SomeInt,
|
TabAllTypes_::SomeInt,
|
||||||
TabAllTypes_::SomeFloat,
|
TabAllTypes_::SomeFloat,
|
||||||
TabAllTypes_::SomeBool,
|
TabAllTypes_::SomeBool,
|
||||||
TabAllTypes_::SomeDate,
|
TabAllTypes_::SomeDayPoint,
|
||||||
TabAllTypes_::SomeDateTime,
|
TabAllTypes_::SomeTimePoint,
|
||||||
TabAllTypes_::OtherInt,
|
TabAllTypes_::OtherInt,
|
||||||
TabAllTypes_::OtherFloat,
|
TabAllTypes_::OtherFloat,
|
||||||
TabAllTypes_::OtherBool,
|
TabAllTypes_::OtherBool,
|
||||||
TabAllTypes_::OtherDate,
|
TabAllTypes_::OtherDayPoint,
|
||||||
TabAllTypes_::OtherDateTime>
|
TabAllTypes_::OtherTimePoint>
|
||||||
{
|
{
|
||||||
struct _alias_t
|
struct _alias_t
|
||||||
{
|
{
|
||||||
|
@ -46,16 +46,16 @@ namespace
|
|||||||
template <typename Assert, typename Operand>
|
template <typename Assert, typename Operand>
|
||||||
void static_check_comparison(const Operand& operand)
|
void static_check_comparison(const Operand& operand)
|
||||||
{
|
{
|
||||||
using CheckResult = sqlpp::check_rhs_comparison_operand_t<decltype(t.someDate), Operand>;
|
using CheckResult = sqlpp::check_rhs_comparison_operand_t<decltype(t.someDayPoint), Operand>;
|
||||||
using ExpectedCheckResult = std::is_same<CheckResult, Assert>;
|
using ExpectedCheckResult = std::is_same<CheckResult, Assert>;
|
||||||
static_assert(ExpectedCheckResult::value, "Unexpected check result");
|
static_assert(ExpectedCheckResult::value, "Unexpected check result");
|
||||||
print_type_on_error<CheckResult>(ExpectedCheckResult{});
|
print_type_on_error<CheckResult>(ExpectedCheckResult{});
|
||||||
|
|
||||||
using ReturnType = sqlpp::detail::make_type_set_t<
|
using ReturnType = sqlpp::detail::make_type_set_t<
|
||||||
decltype(t.someDate < operand), decltype(t.someDate <= operand), decltype(t.someDate == operand),
|
decltype(t.someDayPoint < operand), decltype(t.someDayPoint <= operand), decltype(t.someDayPoint == operand),
|
||||||
decltype(t.someDate != operand), decltype(t.someDate >= operand), decltype(t.someDate > operand),
|
decltype(t.someDayPoint != operand), decltype(t.someDayPoint >= operand), decltype(t.someDayPoint > operand),
|
||||||
decltype(t.someDate.in(operand)), decltype(t.someDate.in(operand, operand)),
|
decltype(t.someDayPoint.in(operand)), decltype(t.someDayPoint.in(operand, operand)),
|
||||||
decltype(t.someDate.not_in(operand)), decltype(t.someDate.not_in(operand, operand))>;
|
decltype(t.someDayPoint.not_in(operand)), decltype(t.someDayPoint.not_in(operand, operand))>;
|
||||||
using ExpectedReturnType =
|
using ExpectedReturnType =
|
||||||
sqlpp::logic::all_t<Assert::value xor
|
sqlpp::logic::all_t<Assert::value xor
|
||||||
std::is_same<ReturnType, sqlpp::detail::type_set<sqlpp::bad_statement>>::value>;
|
std::is_same<ReturnType, sqlpp::detail::type_set<sqlpp::bad_statement>>::value>;
|
||||||
@ -66,8 +66,8 @@ namespace
|
|||||||
void allowed_comparands()
|
void allowed_comparands()
|
||||||
{
|
{
|
||||||
static_check_comparison<sqlpp::consistent_t>(std::chrono::system_clock::now());
|
static_check_comparison<sqlpp::consistent_t>(std::chrono::system_clock::now());
|
||||||
static_check_comparison<sqlpp::consistent_t>(t.someDate);
|
static_check_comparison<sqlpp::consistent_t>(t.someDayPoint);
|
||||||
static_check_comparison<sqlpp::consistent_t>(t.someDateTime);
|
static_check_comparison<sqlpp::consistent_t>(t.someTimePoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void disallowed_comparands()
|
void disallowed_comparands()
|
||||||
|
@ -46,16 +46,16 @@ namespace
|
|||||||
template <typename Assert, typename Operand>
|
template <typename Assert, typename Operand>
|
||||||
void static_check_comparison(const Operand& operand)
|
void static_check_comparison(const Operand& operand)
|
||||||
{
|
{
|
||||||
using CheckResult = sqlpp::check_rhs_comparison_operand_t<decltype(t.someDateTime), Operand>;
|
using CheckResult = sqlpp::check_rhs_comparison_operand_t<decltype(t.someTimePoint), Operand>;
|
||||||
using ExpectedCheckResult = std::is_same<CheckResult, Assert>;
|
using ExpectedCheckResult = std::is_same<CheckResult, Assert>;
|
||||||
static_assert(ExpectedCheckResult::value, "Unexpected check result");
|
static_assert(ExpectedCheckResult::value, "Unexpected check result");
|
||||||
print_type_on_error<CheckResult>(ExpectedCheckResult{});
|
print_type_on_error<CheckResult>(ExpectedCheckResult{});
|
||||||
|
|
||||||
using ReturnType = sqlpp::detail::make_type_set_t<
|
using ReturnType = sqlpp::detail::make_type_set_t<
|
||||||
decltype(t.someDateTime < operand), decltype(t.someDateTime <= operand), decltype(t.someDateTime == operand),
|
decltype(t.someTimePoint < operand), decltype(t.someTimePoint <= operand), decltype(t.someTimePoint == operand),
|
||||||
decltype(t.someDateTime != operand), decltype(t.someDateTime >= operand), decltype(t.someDateTime > operand),
|
decltype(t.someTimePoint != operand), decltype(t.someTimePoint >= operand), decltype(t.someTimePoint > operand),
|
||||||
decltype(t.someDateTime.in(operand)), decltype(t.someDateTime.in(operand, operand)),
|
decltype(t.someTimePoint.in(operand)), decltype(t.someTimePoint.in(operand, operand)),
|
||||||
decltype(t.someDateTime.not_in(operand)), decltype(t.someDateTime.not_in(operand, operand))>;
|
decltype(t.someTimePoint.not_in(operand)), decltype(t.someTimePoint.not_in(operand, operand))>;
|
||||||
using ExpectedReturnType =
|
using ExpectedReturnType =
|
||||||
sqlpp::logic::all_t<Assert::value xor
|
sqlpp::logic::all_t<Assert::value xor
|
||||||
std::is_same<ReturnType, sqlpp::detail::type_set<sqlpp::bad_statement>>::value>;
|
std::is_same<ReturnType, sqlpp::detail::type_set<sqlpp::bad_statement>>::value>;
|
||||||
@ -66,8 +66,8 @@ namespace
|
|||||||
void allowed_comparands()
|
void allowed_comparands()
|
||||||
{
|
{
|
||||||
static_check_comparison<sqlpp::consistent_t>(std::chrono::system_clock::now());
|
static_check_comparison<sqlpp::consistent_t>(std::chrono::system_clock::now());
|
||||||
static_check_comparison<sqlpp::consistent_t>(t.someDate);
|
static_check_comparison<sqlpp::consistent_t>(t.someDayPoint);
|
||||||
static_check_comparison<sqlpp::consistent_t>(t.someDateTime);
|
static_check_comparison<sqlpp::consistent_t>(t.someTimePoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void disallowed_comparands()
|
void disallowed_comparands()
|
||||||
|
@ -42,30 +42,30 @@ int DateTime(int, char**)
|
|||||||
}
|
}
|
||||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||||
{
|
{
|
||||||
std::cout << row.colDate;
|
std::cout << row.colDayPoint;
|
||||||
std::cout << row.colDateTime;
|
std::cout << row.colTimePoint;
|
||||||
}
|
}
|
||||||
printer.reset();
|
printer.reset();
|
||||||
std::cerr << serialize(::sqlpp::value(std::chrono::system_clock::now()), printer).str() << std::endl;
|
std::cerr << serialize(::sqlpp::value(std::chrono::system_clock::now()), printer).str() << std::endl;
|
||||||
|
|
||||||
db(insert_into(t).set(t.colDate = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
db(insert_into(t).set(t.colDayPoint = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
||||||
db(insert_into(t).set(t.colDateTime = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
db(insert_into(t).set(t.colTimePoint = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
||||||
db(insert_into(t).set(t.colDateTime = std::chrono::system_clock::now()));
|
db(insert_into(t).set(t.colTimePoint = std::chrono::system_clock::now()));
|
||||||
|
|
||||||
db(update(t)
|
db(update(t)
|
||||||
.set(t.colDate = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now()))
|
.set(t.colDayPoint = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now()))
|
||||||
.where(t.colDate < std::chrono::system_clock::now()));
|
.where(t.colDayPoint < std::chrono::system_clock::now()));
|
||||||
db(update(t)
|
db(update(t)
|
||||||
.set(t.colDateTime = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now()))
|
.set(t.colTimePoint = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now()))
|
||||||
.where(t.colDate < std::chrono::system_clock::now()));
|
.where(t.colDayPoint < std::chrono::system_clock::now()));
|
||||||
db(update(t)
|
db(update(t)
|
||||||
.set(t.colDateTime = std::chrono::system_clock::now())
|
.set(t.colTimePoint = std::chrono::system_clock::now())
|
||||||
.where(t.colDate < std::chrono::system_clock::now()));
|
.where(t.colDayPoint < std::chrono::system_clock::now()));
|
||||||
|
|
||||||
db(remove_from(t).where(t.colDate == ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
db(remove_from(t).where(t.colDayPoint == ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
||||||
db(remove_from(t).where(t.colDate == std::chrono::system_clock::now()));
|
db(remove_from(t).where(t.colDayPoint == std::chrono::system_clock::now()));
|
||||||
db(remove_from(t).where(t.colDateTime == ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
db(remove_from(t).where(t.colTimePoint == ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())));
|
||||||
db(remove_from(t).where(t.colDateTime == std::chrono::system_clock::now()));
|
db(remove_from(t).where(t.colTimePoint == std::chrono::system_clock::now()));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -215,57 +215,57 @@ namespace test
|
|||||||
|
|
||||||
namespace TabDateTime_
|
namespace TabDateTime_
|
||||||
{
|
{
|
||||||
struct ColDate
|
struct ColDayPoint
|
||||||
{
|
{
|
||||||
struct _alias_t
|
struct _alias_t
|
||||||
{
|
{
|
||||||
static constexpr const char _literal[] = "col_date";
|
static constexpr const char _literal[] = "col_day_point";
|
||||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct _member_t
|
struct _member_t
|
||||||
{
|
{
|
||||||
T colDate;
|
T colDayPoint;
|
||||||
T& operator()()
|
T& operator()()
|
||||||
{
|
{
|
||||||
return colDate;
|
return colDayPoint;
|
||||||
}
|
}
|
||||||
const T& operator()() const
|
const T& operator()() const
|
||||||
{
|
{
|
||||||
return colDate;
|
return colDayPoint;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
using _traits = sqlpp::make_traits<sqlpp::date, sqlpp::tag::can_be_null>;
|
using _traits = sqlpp::make_traits<sqlpp::day_point, sqlpp::tag::can_be_null>;
|
||||||
};
|
};
|
||||||
struct ColDateTime
|
struct ColTimePoint
|
||||||
{
|
{
|
||||||
struct _alias_t
|
struct _alias_t
|
||||||
{
|
{
|
||||||
static constexpr const char _literal[] = "col_date_time";
|
static constexpr const char _literal[] = "col_time_point";
|
||||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct _member_t
|
struct _member_t
|
||||||
{
|
{
|
||||||
T colDateTime;
|
T colTimePoint;
|
||||||
T& operator()()
|
T& operator()()
|
||||||
{
|
{
|
||||||
return colDateTime;
|
return colTimePoint;
|
||||||
}
|
}
|
||||||
const T& operator()() const
|
const T& operator()() const
|
||||||
{
|
{
|
||||||
return colDateTime;
|
return colTimePoint;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
using _traits = sqlpp::make_traits<sqlpp::date_time, sqlpp::tag::can_be_null>;
|
using _traits = sqlpp::make_traits<sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TabDateTime : sqlpp::table_t<TabDateTime, TabDateTime_::ColDate, TabDateTime_::ColDateTime>
|
struct TabDateTime : sqlpp::table_t<TabDateTime, TabDateTime_::ColDayPoint, TabDateTime_::ColTimePoint>
|
||||||
{
|
{
|
||||||
struct _alias_t
|
struct _alias_t
|
||||||
{
|
{
|
||||||
static constexpr const char _literal[] = "tab_date_time";
|
static constexpr const char _literal[] = "tab_time_point";
|
||||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct _member_t
|
struct _member_t
|
||||||
|
Loading…
Reference in New Issue
Block a user