diff --git a/include/sqlpp11/basic_expression_operators.h b/include/sqlpp11/basic_expression_operators.h index ba0a94ff..637d807d 100644 --- a/include/sqlpp11/basic_expression_operators.h +++ b/include/sqlpp11/basic_expression_operators.h @@ -303,14 +303,14 @@ namespace sqlpp template auto operator<<(const R& r) const -> return_type_shift_left_t { - typename return_type_shift_left::check{}; + return_type_shift_left::check::verify(); return {*static_cast(this), wrap_operand_t{r}}; } template auto operator>>(const R& r) const -> return_type_shift_right_t { - typename return_type_shift_right::check{}; + return_type_shift_right::check::verify(); return {*static_cast(this), wrap_operand_t{r}}; } }; diff --git a/include/sqlpp11/chrono.h b/include/sqlpp11/chrono.h index 10c03c7c..8ad24142 100644 --- a/include/sqlpp11/chrono.h +++ b/include/sqlpp11/chrono.h @@ -33,7 +33,7 @@ namespace sqlpp { namespace chrono { - using days = std::chrono::duration, std::chrono::hours::period>>; + using days = std::chrono::duration>; using day_point = std::chrono::time_point; using microsecond_point = std::chrono::time_point; diff --git a/include/sqlpp11/mysql/bind_result.h b/include/sqlpp11/mysql/bind_result.h index d6dc6590..367568ae 100644 --- a/include/sqlpp11/mysql/bind_result.h +++ b/include/sqlpp11/mysql/bind_result.h @@ -372,8 +372,10 @@ namespace sqlpp { const auto& dt = *reinterpret_cast(_handle->result_param_meta_data[index].bound_text_buffer.data()); + if (dt.year > std::numeric_limits::max()) + throw sqlpp::exception("cannot read year from db: " + std::to_string(dt.year)); *is_null = false; - *value = ::date::year(dt.year) / ::date::month(dt.month) / ::date::day(dt.day); + *value = ::date::year(static_cast(dt.year)) / ::date::month(dt.month) / ::date::day(dt.day); } } @@ -387,8 +389,10 @@ namespace sqlpp { const auto& dt = *reinterpret_cast(_handle->result_param_meta_data[index].bound_text_buffer.data()); + if (dt.year > std::numeric_limits::max()) + throw sqlpp::exception("cannot read year from db: " + std::to_string(dt.year)); *is_null = false; - *value = ::sqlpp::chrono::day_point(::date::year(dt.year) / ::date::month(dt.month) / ::date::day(dt.day)) + + *value = ::sqlpp::chrono::day_point(::date::year(static_cast(dt.year)) / ::date::month(dt.month) / ::date::day(dt.day)) + std::chrono::hours(dt.hour) + std::chrono::minutes(dt.minute) + std::chrono::seconds(dt.second) + std::chrono::microseconds(dt.second_part); } @@ -442,7 +446,8 @@ namespace sqlpp param.buffer = r.bound_text_buffer.data(); param.buffer_length = r.bound_text_buffer.size(); - auto err = mysql_stmt_fetch_column(_handle->mysql_stmt, ¶m, r.index, 0); + auto err = + mysql_stmt_fetch_column(_handle->mysql_stmt, ¶m, static_cast(r.index), 0); if (err) throw sqlpp::exception(std::string("MySQL: Fetch column after reallocate failed: ") + "error-code: " + std::to_string(err) + diff --git a/include/sqlpp11/mysql/prepared_statement.h b/include/sqlpp11/mysql/prepared_statement.h index cadb3f2a..d3920603 100644 --- a/include/sqlpp11/mysql/prepared_statement.h +++ b/include/sqlpp11/mysql/prepared_statement.h @@ -159,9 +159,13 @@ namespace sqlpp if (not is_null) { const auto ymd = ::date::year_month_day{*value}; - bound_time.year = static_cast(ymd.year()); + bound_time.year = static_cast(std::abs(static_cast(ymd.year()))); bound_time.month = static_cast(ymd.month()); bound_time.day = static_cast(ymd.day()); + bound_time.hour = 0u; + bound_time.minute = 0u; + bound_time.second = 0u; + bound_time.second_part = 0u; if (_handle->debug) std::cerr << "bound values: " << bound_time.year << '-' << bound_time.month << '-' << bound_time.day << 'T' << bound_time.hour << ':' << bound_time.minute << ':' << bound_time.second << std::endl; @@ -190,13 +194,13 @@ namespace sqlpp const auto dp = ::sqlpp::chrono::floor<::date::days>(*value); const auto time = ::date::make_time(*value - dp); const auto ymd = ::date::year_month_day{dp}; - bound_time.year = static_cast(ymd.year()); + bound_time.year = static_cast(std::abs(static_cast(ymd.year()))); bound_time.month = static_cast(ymd.month()); bound_time.day = static_cast(ymd.day()); - bound_time.hour = time.hours().count(); - bound_time.minute = time.minutes().count(); - bound_time.second = time.seconds().count(); - bound_time.second_part = time.subseconds().count(); + bound_time.hour = static_cast(time.hours().count()); + bound_time.minute = static_cast(time.minutes().count()); + bound_time.second = static_cast(time.seconds().count()); + bound_time.second_part = static_cast(time.subseconds().count()); if (_handle->debug) std::cerr << "bound values: " << bound_time.year << '-' << bound_time.month << '-' << bound_time.day << 'T' << bound_time.hour << ':' << bound_time.minute << ':' << bound_time.second << std::endl; diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 20a827b0..e102058e 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -362,7 +362,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - static constexpr auto _check_args(std::tuple args) -> check_selected_columns_t + static constexpr auto _check_args(std::tuple /*args*/) -> check_selected_columns_t { return {}; } diff --git a/tests/core/serialize/Operator.cpp b/tests/core/serialize/Operator.cpp index 1fe8a09e..3228c6d2 100644 --- a/tests/core/serialize/Operator.cpp +++ b/tests/core/serialize/Operator.cpp @@ -29,8 +29,6 @@ #include -SQLPP_ALIAS_PROVIDER(sample) - int Operator(int, char* []) { const auto foo = test::TabFoo{}; diff --git a/tests/core/usage/With.cpp b/tests/core/usage/With.cpp index fbd2995f..c93a2511 100644 --- a/tests/core/usage/With.cpp +++ b/tests/core/usage/With.cpp @@ -63,11 +63,10 @@ int With(int, char*[]) select(t.alpha, t.delta).from(t.join(initialCte).on(t.alpha == initialCte.delta)).unconditionally()); const auto query = with(recursiveCte)(select(recursiveCte.alpha).from(recursiveCte).unconditionally()); - ::MockDb::_serializer_context_t printer = {}; + printer.reset(); const auto serializedQuery = serialize(query, printer).str(); std::cout << serializedQuery << '\n'; - auto db = MockDb{}; for (const auto& row : db(query)) { std::cout << row.alpha; diff --git a/tests/mysql/usage/CustomQuery.cpp b/tests/mysql/usage/CustomQuery.cpp index 32794fc5..3c2a0f3f 100644 --- a/tests/mysql/usage/CustomQuery.cpp +++ b/tests/mysql/usage/CustomQuery.cpp @@ -29,8 +29,6 @@ #include #include -SQLPP_ALIAS_PROVIDER(left) -SQLPP_ALIAS_PROVIDER(right) namespace { struct on_duplicate_key_update diff --git a/tests/mysql/usage/DateTime.cpp b/tests/mysql/usage/DateTime.cpp index 8ca0402b..f0b50bae 100644 --- a/tests/mysql/usage/DateTime.cpp +++ b/tests/mysql/usage/DateTime.cpp @@ -136,9 +136,9 @@ int DateTime(int, char*[]) require_equal(__LINE__, row.colTimePoint.value(), today); } - auto x = update(tab) - .set(tab.colDayPoint = parameter(tab.colDayPoint), tab.colTimePoint = parameter(tab.colTimePoint)) - .unconditionally(); + update(tab) + .set(tab.colDayPoint = parameter(tab.colDayPoint), tab.colTimePoint = parameter(tab.colTimePoint)) + .unconditionally(); auto prepared_update = db.prepare( update(tab) diff --git a/tests/mysql/usage/Prepared.cpp b/tests/mysql/usage/Prepared.cpp index 3115a5fe..dab86a69 100644 --- a/tests/mysql/usage/Prepared.cpp +++ b/tests/mysql/usage/Prepared.cpp @@ -39,8 +39,6 @@ const auto library_raii = sqlpp::mysql::scoped_library_initializer_t{0, nullptr, nullptr}; -SQLPP_ALIAS_PROVIDER(left) - namespace sql = sqlpp::mysql; const auto tab = TabSample{};