mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-05 20:50:34 -06:00
Fix serialization of time points for MySQL. (#503)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user