diff --git a/include/sqlpp11/column_types.h b/include/sqlpp11/column_types.h index 662d4179..bfc28128 100644 --- a/include/sqlpp11/column_types.h +++ b/include/sqlpp11/column_types.h @@ -28,8 +28,8 @@ #define SQLPP_COLUMN_TYPES_H #include -#include -#include +#include +#include #include #include #include diff --git a/include/sqlpp11/date_time_fwd.h b/include/sqlpp11/date_time_fwd.h index 9ca9be00..3855dc1c 100644 --- a/include/sqlpp11/date_time_fwd.h +++ b/include/sqlpp11/date_time_fwd.h @@ -39,8 +39,8 @@ namespace sqlpp using mus_point = std::chrono::time_point; } - struct date; - struct date_time; + struct day_point; + struct time_point; } #endif diff --git a/include/sqlpp11/date.h b/include/sqlpp11/day_point.h similarity index 81% rename from include/sqlpp11/date.h rename to include/sqlpp11/day_point.h index ce1d645a..31072a7e 100644 --- a/include/sqlpp11/date.h +++ b/include/sqlpp11/day_point.h @@ -24,11 +24,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SQLPP_DATE_H -#define SQLPP_DATE_H +#ifndef SQLPP_DAY_POINT_H +#define SQLPP_DAY_POINT_H #include -#include +#include #include #include #include @@ -38,10 +38,10 @@ namespace sqlpp { - // date value type - struct date + // day_point value type + struct day_point { - using _traits = make_traits; + using _traits = make_traits; using _tag = tag::is_date; using _cpp_value_type = ::sqlpp::chrono::day_point; @@ -51,11 +51,11 @@ namespace sqlpp using _is_valid_assignment_operand = is_date_t; }; - // date parameter value + // day_point parameter value template <> - struct parameter_value_t + struct parameter_value_t { - using _value_type = date; + using _value_type = day_point; using _cpp_value_type = typename _value_type::_cpp_value_type; parameter_value_t() : _value{}, _is_null(true) @@ -120,28 +120,29 @@ namespace sqlpp bool _is_null; }; - // date expression operators + // day_point expression operators template - struct expression_operators : public basic_expression_operators + struct expression_operators : public basic_expression_operators { template - using _is_valid_operand = is_valid_operand; + using _is_valid_operand = is_valid_operand; }; - // date column operators + // day_point column operators template - struct column_operators + struct column_operators { template - using _is_valid_operand = is_valid_operand; + using _is_valid_operand = is_valid_operand; }; - // date result field + // day_point result field template - struct result_field_t : public result_field_methods_t> + struct result_field_t + : public result_field_methods_t> { - static_assert(std::is_same, date>::value, "field type mismatch"); - using _cpp_value_type = typename sqlpp::date::_cpp_value_type; + static_assert(std::is_same, day_point>::value, "field type mismatch"); + using _cpp_value_type = typename sqlpp::day_point::_cpp_value_type; result_field_t() : _is_valid(false), _is_null(true), _value{} { @@ -206,10 +207,10 @@ namespace sqlpp }; template - struct serializer_t> + struct serializer_t> { using _serialize_check = consistent_t; - using T = result_field_t; + using T = result_field_t; static Context& _(const T& t, Context& context) { @@ -227,7 +228,7 @@ namespace sqlpp }; template - inline std::ostream& operator<<(std::ostream& os, const result_field_t& e) + inline std::ostream& operator<<(std::ostream& os, const result_field_t& e) { return serialize(e, os); } diff --git a/include/sqlpp11/date_time.h b/include/sqlpp11/time_point.h similarity index 82% rename from include/sqlpp11/date_time.h rename to include/sqlpp11/time_point.h index 9b1933ea..a1686366 100644 --- a/include/sqlpp11/date_time.h +++ b/include/sqlpp11/time_point.h @@ -24,8 +24,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SQLPP_DATE_TIME_H -#define SQLPP_DATE_TIME_H +#ifndef SQLPP_TIME_POINT_H +#define SQLPP_TIME_POINT_H #include #include @@ -37,10 +37,10 @@ namespace sqlpp { - // date_time value type - struct date_time + // time_point value type + struct time_point { - using _traits = make_traits; + using _traits = make_traits; using _tag = tag::is_date_time; using _cpp_value_type = ::sqlpp::chrono::mus_point; @@ -48,11 +48,11 @@ namespace sqlpp using _is_valid_operand = is_time_point_t; }; - // date_time parameter value + // time_point parameter value template <> - struct parameter_value_t + struct parameter_value_t { - using _value_type = date_time; + using _value_type = time_point; using _cpp_value_type = typename _value_type::_cpp_value_type; parameter_value_t() : _value{}, _is_null(true) @@ -117,29 +117,29 @@ namespace sqlpp bool _is_null; }; - // date_time expression operators + // time_point expression operators template - struct expression_operators : public basic_expression_operators + struct expression_operators : public basic_expression_operators { template - using _is_valid_operand = is_valid_operand; + using _is_valid_operand = is_valid_operand; }; - // date_time column operators + // time_point column operators template - struct column_operators + struct column_operators { template - using _is_valid_operand = is_valid_operand; + using _is_valid_operand = is_valid_operand; }; - // date_time result field + // time_point result field template - struct result_field_t - : public result_field_methods_t> + struct result_field_t + : public result_field_methods_t> { - static_assert(std::is_same, date_time>::value, "field type mismatch"); - using _cpp_value_type = typename date_time::_cpp_value_type; + static_assert(std::is_same, time_point>::value, "field type mismatch"); + using _cpp_value_type = typename time_point::_cpp_value_type; result_field_t() : _is_valid(false), _is_null(true), _value{} { @@ -204,10 +204,10 @@ namespace sqlpp }; template - struct serializer_t> + struct serializer_t> { using _serialize_check = consistent_t; - using T = result_field_t; + using T = result_field_t; static Context& _(const T& t, Context& context) { @@ -227,7 +227,7 @@ namespace sqlpp }; template - inline std::ostream& operator<<(std::ostream& os, const result_field_t& e) + inline std::ostream& operator<<(std::ostream& os, const result_field_t& e) { return serialize(e, os); } diff --git a/include/sqlpp11/wrap_operand.h b/include/sqlpp11/wrap_operand.h index 92925b2e..51c6304f 100644 --- a/include/sqlpp11/wrap_operand.h +++ b/include/sqlpp11/wrap_operand.h @@ -85,27 +85,27 @@ namespace sqlpp } }; - struct date_operand : public alias_operators + struct day_point_operand : public alias_operators { - using _traits = make_traits; + using _traits = make_traits; using _nodes = detail::type_vector<>; using _is_aggregate_expression = std::true_type; 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; - date_operand(date_operand&&) = default; - date_operand& operator=(const date_operand&) = default; - date_operand& operator=(date_operand&&) = default; - ~date_operand() = default; + day_point_operand(const day_point_operand&) = default; + day_point_operand(day_point_operand&&) = default; + day_point_operand& operator=(const day_point_operand&) = default; + day_point_operand& operator=(day_point_operand&&) = default; + ~day_point_operand() = default; bool _is_trivial() const { @@ -116,10 +116,10 @@ namespace sqlpp }; template - struct serializer_t + struct serializer_t { using _serialize_check = consistent_t; - using Operand = date_operand; + using Operand = day_point_operand; static Context& _(const Operand& t, Context& context) { @@ -130,27 +130,27 @@ namespace sqlpp }; template - struct date_time_operand : public alias_operators> + struct time_point_operand : public alias_operators> { - using _traits = make_traits; + using _traits = make_traits; using _nodes = detail::type_vector<>; using _is_aggregate_expression = std::true_type; using _value_t = std::chrono::time_point; - 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; - date_time_operand(date_time_operand&&) = default; - date_time_operand& operator=(const date_time_operand&) = default; - date_time_operand& operator=(date_time_operand&&) = default; - ~date_time_operand() = default; + time_point_operand(const time_point_operand&) = default; + time_point_operand(time_point_operand&&) = default; + time_point_operand& operator=(const time_point_operand&) = default; + time_point_operand& operator=(time_point_operand&&) = default; + ~time_point_operand() = default; bool _is_trivial() const { @@ -161,10 +161,10 @@ namespace sqlpp }; template - struct serializer_t> + struct serializer_t> { using _serialize_check = consistent_t; - using Operand = date_time_operand; + using Operand = time_point_operand; static Context& _(const Operand& t, Context& context) { @@ -320,13 +320,13 @@ namespace sqlpp template struct wrap_operand, void> { - using type = date_time_operand; + using type = time_point_operand; }; template <> struct wrap_operand, void> { - using type = date_operand; + using type = day_point_operand; }; template diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index 52af8e4d..6a8c7af2 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -101,8 +101,8 @@ types = { 'boolean': 'boolean', 'double': 'floating_point', 'float': 'floating_point', - 'date' : 'date', - 'datetime' : 'date_time', + 'date' : 'day_point', + 'datetime' : 'time_point', } # PROCESS DDL diff --git a/test_static_asserts/AssertTables.h b/test_static_asserts/AssertTables.h index 6c6cdef3..e002f1b9 100644 --- a/test_static_asserts/AssertTables.h +++ b/test_static_asserts/AssertTables.h @@ -98,49 +98,49 @@ namespace test }; using _traits = sqlpp::make_traits; }; - struct SomeDate + struct SomeDayPoint { 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; template struct _member_t { - T someDate; + T someDayPoint; T& operator()() { - return someDate; + return someDayPoint; } const T& operator()() const { - return someDate; + return someDayPoint; } }; }; - using _traits = sqlpp::make_traits; + using _traits = sqlpp::make_traits; }; - struct SomeDateTime + struct SomeTimePoint { 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; template struct _member_t { - T someDateTime; + T someTimePoint; T& operator()() { - return someDateTime; + return someTimePoint; } const T& operator()() const { - return someDateTime; + return someTimePoint; } }; }; - using _traits = sqlpp::make_traits; + using _traits = sqlpp::make_traits; }; struct OtherInt { @@ -208,49 +208,49 @@ namespace test }; using _traits = sqlpp::make_traits; }; - struct OtherDate + struct OtherDayPoint { 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; template struct _member_t { - T otherDate; + T otherDayPoint; T& operator()() { - return otherDate; + return otherDayPoint; } const T& operator()() const { - return otherDate; + return otherDayPoint; } }; }; - using _traits = sqlpp::make_traits; + using _traits = sqlpp::make_traits; }; - struct OtherDateTime + struct OtherTimePoint { 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; template struct _member_t { - T otherDateTime; + T otherTimePoint; T& operator()() { - return otherDateTime; + return otherTimePoint; } const T& operator()() const { - return otherDateTime; + return otherTimePoint; } }; }; - using _traits = sqlpp::make_traits; + using _traits = sqlpp::make_traits; }; } @@ -259,13 +259,13 @@ namespace test TabAllTypes_::SomeInt, TabAllTypes_::SomeFloat, TabAllTypes_::SomeBool, - TabAllTypes_::SomeDate, - TabAllTypes_::SomeDateTime, + TabAllTypes_::SomeDayPoint, + TabAllTypes_::SomeTimePoint, TabAllTypes_::OtherInt, TabAllTypes_::OtherFloat, TabAllTypes_::OtherBool, - TabAllTypes_::OtherDate, - TabAllTypes_::OtherDateTime> + TabAllTypes_::OtherDayPoint, + TabAllTypes_::OtherTimePoint> { struct _alias_t { diff --git a/test_static_asserts/date.cpp b/test_static_asserts/date.cpp index ea7dc9e1..a388c5e1 100644 --- a/test_static_asserts/date.cpp +++ b/test_static_asserts/date.cpp @@ -46,16 +46,16 @@ namespace template void static_check_comparison(const Operand& operand) { - using CheckResult = sqlpp::check_rhs_comparison_operand_t; + using CheckResult = sqlpp::check_rhs_comparison_operand_t; using ExpectedCheckResult = std::is_same; static_assert(ExpectedCheckResult::value, "Unexpected check result"); print_type_on_error(ExpectedCheckResult{}); using ReturnType = sqlpp::detail::make_type_set_t< - decltype(t.someDate < operand), decltype(t.someDate <= operand), decltype(t.someDate == operand), - decltype(t.someDate != operand), decltype(t.someDate >= operand), decltype(t.someDate > operand), - decltype(t.someDate.in(operand)), decltype(t.someDate.in(operand, operand)), - decltype(t.someDate.not_in(operand)), decltype(t.someDate.not_in(operand, operand))>; + decltype(t.someDayPoint < operand), decltype(t.someDayPoint <= operand), decltype(t.someDayPoint == operand), + decltype(t.someDayPoint != operand), decltype(t.someDayPoint >= operand), decltype(t.someDayPoint > operand), + decltype(t.someDayPoint.in(operand)), decltype(t.someDayPoint.in(operand, operand)), + decltype(t.someDayPoint.not_in(operand)), decltype(t.someDayPoint.not_in(operand, operand))>; using ExpectedReturnType = sqlpp::logic::all_t>::value>; @@ -66,8 +66,8 @@ namespace void allowed_comparands() { static_check_comparison(std::chrono::system_clock::now()); - static_check_comparison(t.someDate); - static_check_comparison(t.someDateTime); + static_check_comparison(t.someDayPoint); + static_check_comparison(t.someTimePoint); } void disallowed_comparands() diff --git a/test_static_asserts/date_time.cpp b/test_static_asserts/date_time.cpp index 1b184208..32e03129 100644 --- a/test_static_asserts/date_time.cpp +++ b/test_static_asserts/date_time.cpp @@ -46,16 +46,16 @@ namespace template void static_check_comparison(const Operand& operand) { - using CheckResult = sqlpp::check_rhs_comparison_operand_t; + using CheckResult = sqlpp::check_rhs_comparison_operand_t; using ExpectedCheckResult = std::is_same; static_assert(ExpectedCheckResult::value, "Unexpected check result"); print_type_on_error(ExpectedCheckResult{}); using ReturnType = sqlpp::detail::make_type_set_t< - decltype(t.someDateTime < operand), decltype(t.someDateTime <= operand), decltype(t.someDateTime == operand), - decltype(t.someDateTime != operand), decltype(t.someDateTime >= operand), decltype(t.someDateTime > operand), - decltype(t.someDateTime.in(operand)), decltype(t.someDateTime.in(operand, operand)), - decltype(t.someDateTime.not_in(operand)), decltype(t.someDateTime.not_in(operand, operand))>; + decltype(t.someTimePoint < operand), decltype(t.someTimePoint <= operand), decltype(t.someTimePoint == operand), + decltype(t.someTimePoint != operand), decltype(t.someTimePoint >= operand), decltype(t.someTimePoint > operand), + decltype(t.someTimePoint.in(operand)), decltype(t.someTimePoint.in(operand, operand)), + decltype(t.someTimePoint.not_in(operand)), decltype(t.someTimePoint.not_in(operand, operand))>; using ExpectedReturnType = sqlpp::logic::all_t>::value>; @@ -66,8 +66,8 @@ namespace void allowed_comparands() { static_check_comparison(std::chrono::system_clock::now()); - static_check_comparison(t.someDate); - static_check_comparison(t.someDateTime); + static_check_comparison(t.someDayPoint); + static_check_comparison(t.someTimePoint); } void disallowed_comparands() diff --git a/tests/DateTime.cpp b/tests/DateTime.cpp index 1b76446e..10c90d34 100644 --- a/tests/DateTime.cpp +++ b/tests/DateTime.cpp @@ -42,30 +42,30 @@ int DateTime(int, char**) } for (const auto& row : db(select(all_of(t)).from(t).where(true))) { - std::cout << row.colDate; - std::cout << row.colDateTime; + std::cout << row.colDayPoint; + std::cout << row.colTimePoint; } printer.reset(); 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.colDateTime = ::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.colDayPoint = ::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.colTimePoint = std::chrono::system_clock::now())); db(update(t) - .set(t.colDate = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())) - .where(t.colDate < std::chrono::system_clock::now())); + .set(t.colDayPoint = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())) + .where(t.colDayPoint < std::chrono::system_clock::now())); db(update(t) - .set(t.colDateTime = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())) - .where(t.colDate < std::chrono::system_clock::now())); + .set(t.colTimePoint = ::date::floor<::sqlpp::chrono::days>(std::chrono::system_clock::now())) + .where(t.colDayPoint < std::chrono::system_clock::now())); db(update(t) - .set(t.colDateTime = std::chrono::system_clock::now()) - .where(t.colDate < std::chrono::system_clock::now())); + .set(t.colTimePoint = 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.colDate == 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.colDateTime == 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.colDayPoint == 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.colTimePoint == std::chrono::system_clock::now())); return 0; } diff --git a/tests/Sample.h b/tests/Sample.h index 44a2d274..adda22db 100644 --- a/tests/Sample.h +++ b/tests/Sample.h @@ -215,57 +215,57 @@ namespace test namespace TabDateTime_ { - struct ColDate + struct ColDayPoint { 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; template struct _member_t { - T colDate; + T colDayPoint; T& operator()() { - return colDate; + return colDayPoint; } const T& operator()() const { - return colDate; + return colDayPoint; } }; }; - using _traits = sqlpp::make_traits; + using _traits = sqlpp::make_traits; }; - struct ColDateTime + struct ColTimePoint { 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; template struct _member_t { - T colDateTime; + T colTimePoint; T& operator()() { - return colDateTime; + return colTimePoint; } const T& operator()() const { - return colDateTime; + return colTimePoint; } }; }; - using _traits = sqlpp::make_traits; + using _traits = sqlpp::make_traits; }; } - struct TabDateTime : sqlpp::table_t + struct TabDateTime : sqlpp::table_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; template struct _member_t