Use a different Date data type
PLEASE backup your database before testing this commit, and report any migration issue. In postgresql, we use timestamp with timezone. In sqlite3 we use REAL (the date is expressed as julianday) This requires a migration of the muclogline_ table: In postgresql it’s pretty simple, we convert all the integer into timestamps With sqlite3, we actually rename the table, create the new one with the correct type, then copy everything to the new table, with a conversion function for the Date_ column, and then we delete the old table. fix #3343
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
#include <database/engine.hpp>
|
||||
|
||||
#include <database/statement.hpp>
|
||||
#include <utils/datetime.hpp>
|
||||
#include <database/query.hpp>
|
||||
#include <logger/logger.hpp>
|
||||
#include <database/row.hpp>
|
||||
|
||||
#include <utils/optional_bool.hpp>
|
||||
@@ -41,6 +41,14 @@ extract_row_value(Statement& statement, const int i)
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_same<DateTime, T>::value, T>::type
|
||||
extract_row_value(Statement& statement, const int i)
|
||||
{
|
||||
const std::string timestamp = statement.get_column_text(i);
|
||||
return {timestamp};
|
||||
}
|
||||
|
||||
template <std::size_t N=0, typename... T>
|
||||
typename std::enable_if<N < sizeof...(T), void>::type
|
||||
extract_row_values(Row<T...>& row, Statement& statement)
|
||||
@@ -58,6 +66,18 @@ typename std::enable_if<N == sizeof...(T), void>::type
|
||||
extract_row_values(Row<T...>&, Statement&)
|
||||
{}
|
||||
|
||||
template <typename ColumnType>
|
||||
std::string before_column()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename ColumnType>
|
||||
std::string after_column()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
struct SelectQuery: public Query
|
||||
{
|
||||
@@ -76,7 +96,8 @@ struct SelectQuery: public Query
|
||||
using ColumnsType = std::tuple<T...>;
|
||||
using ColumnType = typename std::remove_reference<decltype(std::get<N>(std::declval<ColumnsType>()))>::type;
|
||||
|
||||
this->body += " " + std::string{ColumnType::name};
|
||||
this->body += " ";
|
||||
this->body += before_column<ColumnType>() + ColumnType::name + after_column<ColumnType>();
|
||||
|
||||
if (N < (sizeof...(T) - 1))
|
||||
this->body += ", ";
|
||||
|
||||
Reference in New Issue
Block a user