0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Fix compiler warnings.

This commit is contained in:
Roland Bock 2021-12-11 19:53:35 +01:00
parent 91b7b34557
commit 181cc5fb04
10 changed files with 26 additions and 24 deletions

View File

@ -303,14 +303,14 @@ namespace sqlpp
template <typename R>
auto operator<<(const R& r) const -> return_type_shift_left_t<Expr, R>
{
typename return_type_shift_left<Expr, R>::check{};
return_type_shift_left<Expr, R>::check::verify();
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
}
template <typename R>
auto operator>>(const R& r) const -> return_type_shift_right_t<Expr, R>
{
typename return_type_shift_right<Expr, R>::check{};
return_type_shift_right<Expr, R>::check::verify();
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
}
};

View File

@ -33,7 +33,7 @@ namespace sqlpp
{
namespace chrono
{
using days = std::chrono::duration<int, std::ratio_multiply<std::ratio<24>, std::chrono::hours::period>>;
using days = std::chrono::duration<int, std::ratio<86400, 1>>;
using day_point = std::chrono::time_point<std::chrono::system_clock, days>;
using microsecond_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::microseconds>;

View File

@ -372,8 +372,10 @@ namespace sqlpp
{
const auto& dt =
*reinterpret_cast<const MYSQL_TIME*>(_handle->result_param_meta_data[index].bound_text_buffer.data());
if (dt.year > std::numeric_limits<int>::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<int>(dt.year)) / ::date::month(dt.month) / ::date::day(dt.day);
}
}
@ -387,8 +389,10 @@ namespace sqlpp
{
const auto& dt =
*reinterpret_cast<const MYSQL_TIME*>(_handle->result_param_meta_data[index].bound_text_buffer.data());
if (dt.year > std::numeric_limits<int>::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<int>(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, &param, r.index, 0);
auto err =
mysql_stmt_fetch_column(_handle->mysql_stmt, &param, static_cast<unsigned int>(r.index), 0);
if (err)
throw sqlpp::exception(std::string("MySQL: Fetch column after reallocate failed: ") +
"error-code: " + std::to_string(err) +

View File

@ -159,9 +159,13 @@ namespace sqlpp
if (not is_null)
{
const auto ymd = ::date::year_month_day{*value};
bound_time.year = static_cast<int>(ymd.year());
bound_time.year = static_cast<unsigned>(std::abs(static_cast<int>(ymd.year())));
bound_time.month = static_cast<unsigned>(ymd.month());
bound_time.day = static_cast<unsigned>(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<int>(ymd.year());
bound_time.year = static_cast<unsigned>(std::abs(static_cast<int>(ymd.year())));
bound_time.month = static_cast<unsigned>(ymd.month());
bound_time.day = static_cast<unsigned>(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<unsigned>(time.hours().count());
bound_time.minute = static_cast<unsigned>(time.minutes().count());
bound_time.second = static_cast<unsigned>(time.seconds().count());
bound_time.second_part = static_cast<unsigned long>(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;

View File

@ -362,7 +362,7 @@ namespace sqlpp
using _database_t = typename Policies::_database_t;
template <typename... T>
static constexpr auto _check_args(std::tuple<T...> args) -> check_selected_columns_t<T...>
static constexpr auto _check_args(std::tuple<T...> /*args*/) -> check_selected_columns_t<T...>
{
return {};
}

View File

@ -29,8 +29,6 @@
#include <iostream>
SQLPP_ALIAS_PROVIDER(sample)
int Operator(int, char* [])
{
const auto foo = test::TabFoo{};

View File

@ -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;

View File

@ -29,8 +29,6 @@
#include <sqlpp11/custom_query.h>
#include <sqlpp11/mysql/mysql.h>
SQLPP_ALIAS_PROVIDER(left)
SQLPP_ALIAS_PROVIDER(right)
namespace
{
struct on_duplicate_key_update

View File

@ -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)

View File

@ -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{};