Skip to content

Commit 4a1ed2c

Browse files
Fix serialization of time points for MySQL. (#503)
1 parent dff8c23 commit 4a1ed2c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

include/sqlpp11/data_types/time_point/operand.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ namespace sqlpp
6767
const auto dp = ::sqlpp::chrono::floor<::date::days>(t._t);
6868
const auto time = ::date::make_time(t._t - dp);
6969
const auto ymd = ::date::year_month_day{dp};
70-
context << "TIMESTAMP WITH TIME ZONE '" << ymd << ' ' << time << "+00'";
70+
context << "TIMESTAMP '" << ymd << ' ' << time << "'";
7171
return context;
7272
}
7373
} // namespace sqlpp

include/sqlpp11/postgresql/serializer.h

+11
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#ifndef SQLPP_POSTGRESQL_SERIALIZER_H
2929
#define SQLPP_POSTGRESQL_SERIALIZER_H
3030

31+
#include <sqlpp11/chrono.h>
3132
#include <sqlpp11/parameter.h>
3233
#include <sqlpp11/wrap_operand.h>
3334

@@ -54,6 +55,16 @@ namespace sqlpp
5455

5556
return context;
5657
}
58+
59+
template <typename Period>
60+
postgresql::context_t& serialize(const time_point_operand<Period>& t, postgresql::context_t& context)
61+
{
62+
const auto dp = ::sqlpp::chrono::floor<::date::days>(t._t);
63+
const auto time = ::date::make_time(t._t - dp);
64+
const auto ymd = ::date::year_month_day{dp};
65+
context << "TIMESTAMP WITH TIME ZONE '" << ymd << ' ' << time << "+00'";
66+
return context;
67+
}
5768
}
5869

5970
#endif

0 commit comments

Comments
 (0)