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:
MeanSquaredError
2023-07-24 07:40:18 +03:00
committed by GitHub
parent 4a1ed2c02e
commit 4295c29e9a
4 changed files with 15 additions and 9 deletions
+2 -1
View File
@@ -131,7 +131,8 @@ int TimeZone(int, char*[])
{
namespace sql = sqlpp::postgresql;
auto dbc = sql::make_test_connection();
// We use a time zone with non-zero offset from UTC in order to catch serialization/parsing bugs
auto dbc = sql::make_test_connection("+1");
dbc.execute("DROP TABLE IF EXISTS tabdatetime;");
dbc.execute(
@@ -51,7 +51,7 @@ namespace sqlpp
}
// Starts a connection and sets the time zone to UTC
inline ::sqlpp::postgresql::connection make_test_connection()
inline ::sqlpp::postgresql::connection make_test_connection(const std::string &tz = "UTC")
{
namespace sql = sqlpp::postgresql;
@@ -69,7 +69,7 @@ namespace sqlpp
throw;
}
db.execute(R"(SET TIME ZONE 'UTC';)");
db.execute("SET TIME ZONE " + tz + ";");
return db;
}