Fix serialization of time points for MySQL. (#503)

This commit is contained in:
MeanSquaredError
2023-07-23 11:40:27 +03:00
committed by GitHub
parent dff8c23b22
commit 4a1ed2c02e
2 changed files with 12 additions and 1 deletions

View File

@@ -67,7 +67,7 @@ namespace sqlpp
const auto dp = ::sqlpp::chrono::floor<::date::days>(t._t);
const auto time = ::date::make_time(t._t - dp);
const auto ymd = ::date::year_month_day{dp};
context << "TIMESTAMP WITH TIME ZONE '" << ymd << ' ' << time << "+00'";
context << "TIMESTAMP '" << ymd << ' ' << time << "'";
return context;
}
} // namespace sqlpp

View File

@@ -28,6 +28,7 @@
#ifndef SQLPP_POSTGRESQL_SERIALIZER_H
#define SQLPP_POSTGRESQL_SERIALIZER_H
#include <sqlpp11/chrono.h>
#include <sqlpp11/parameter.h>
#include <sqlpp11/wrap_operand.h>
@@ -54,6 +55,16 @@ namespace sqlpp
return context;
}
template <typename Period>
postgresql::context_t& serialize(const time_point_operand<Period>& t, postgresql::context_t& context)
{
const auto dp = ::sqlpp::chrono::floor<::date::days>(t._t);
const auto time = ::date::make_time(t._t - dp);
const auto ymd = ::date::year_month_day{dp};
context << "TIMESTAMP WITH TIME ZONE '" << ymd << ' ' << time << "+00'";
return context;
}
}
#endif