summaryrefslogtreecommitdiff
path: root/src/database/select_query.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/database/select_query.hpp')
-rw-r--r--src/database/select_query.hpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/database/select_query.hpp b/src/database/select_query.hpp
index 743a011..3013dd8 100644
--- a/src/database/select_query.hpp
+++ b/src/database/select_query.hpp
@@ -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 += ", ";