mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-05 04:30:43 -06:00
Fix serialization of PostgreSQL time data types (#504)
* Use a non-UTC timezone when testing the PostgreSQL timezone support. * Fix serialization of time of day values for PostgreSQL * Fix serialization of PostgreSQL values for "timestamp with time zone" and "time with time zone" fields.
This commit is contained in:
@@ -199,10 +199,9 @@ namespace sqlpp
|
||||
{
|
||||
const auto time = ::date::make_time(*value) ;
|
||||
|
||||
// Timezone handling - always treat the value as UTC.
|
||||
// It is assumed that the database timezone is set to UTC, too.
|
||||
// Timezone handling - always treat the local value as UTC.
|
||||
std::ostringstream os;
|
||||
os << time;
|
||||
os << time << "+00";
|
||||
_handle->paramValues[index] = os.str();
|
||||
if (_handle->debug())
|
||||
{
|
||||
@@ -225,10 +224,9 @@ namespace sqlpp
|
||||
const auto time = ::date::make_time(::sqlpp::chrono::floor<::std::chrono::microseconds>(*value - dp));
|
||||
const auto ymd = ::date::year_month_day{dp};
|
||||
|
||||
// Timezone handling - always treat the value as UTC.
|
||||
// It is assumed that the database timezone is set to UTC, too.
|
||||
// Timezone handling - always treat the local value as UTC.
|
||||
std::ostringstream os;
|
||||
os << ymd << ' ' << time;
|
||||
os << ymd << ' ' << time << "+00";
|
||||
_handle->paramValues[index] = os.str();
|
||||
if (_handle->debug())
|
||||
{
|
||||
|
||||
@@ -65,6 +65,13 @@ namespace sqlpp
|
||||
context << "TIMESTAMP WITH TIME ZONE '" << ymd << ' ' << time << "+00'";
|
||||
return context;
|
||||
}
|
||||
|
||||
template <typename Period>
|
||||
postgresql::context_t& serialize(const time_of_day_operand<Period>& t, postgresql::context_t& context)
|
||||
{
|
||||
context << "TIME WITH TIME ZONE '" << ::date::make_time(t._t) << "+00'";
|
||||
return context;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user