diff options
author | louiz’ <louiz@louiz.org> | 2018-04-13 23:35:06 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2018-04-13 23:35:06 +0200 |
commit | 4bd7b6981bb49dd4111c908aaa34c34f677171f4 (patch) | |
tree | 918347adb112c04455e23fcad06626e5635b6ad4 /src/database/insert_query.hpp | |
parent | de8267fa3f4f4e1d61bcf35fb36c6664f520a385 (diff) | |
download | biboumi-4bd7b6981bb49dd4111c908aaa34c34f677171f4.tar.gz biboumi-4bd7b6981bb49dd4111c908aaa34c34f677171f4.tar.bz2 biboumi-4bd7b6981bb49dd4111c908aaa34c34f677171f4.tar.xz biboumi-4bd7b6981bb49dd4111c908aaa34c34f677171f4.zip |
Refactor that fixes a compilation issue in Release mode
Some template specialization were not found, because they were not declared
at the point they were used.
We moved things around, things are less inter-dependant, and also now it
works.
Diffstat (limited to 'src/database/insert_query.hpp')
-rw-r--r-- | src/database/insert_query.hpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/database/insert_query.hpp b/src/database/insert_query.hpp index e3a7e83..cd1942f 100644 --- a/src/database/insert_query.hpp +++ b/src/database/insert_query.hpp @@ -1,10 +1,15 @@ #pragma once #include <database/statement.hpp> +#include <database/database.hpp> #include <database/column.hpp> #include <database/query.hpp> +#include <database/row.hpp> + #include <logger/logger.hpp> +#include <utils/is_one_of.hpp> + #include <type_traits> #include <vector> #include <string> @@ -37,6 +42,12 @@ std::string after_value() return {}; } +template <> +std::string before_value<Database::Date>(); + +template <> +std::string after_value<Database::Date>(); + struct InsertQuery: public Query { template <typename... T> @@ -141,3 +152,13 @@ struct InsertQuery: public Query insert_col_name(const std::tuple<T...>&) {} }; + +template <typename... T> +void insert(Row<T...>& row, DatabaseEngine& db) +{ + InsertQuery query(row.table_name, row.columns); + // Ugly workaround for non portable stuff + if (is_one_of<Id, T...>) + query.body += db.get_returning_id_sql_string(Id::name); + query.execute(db, row.columns); +} |