summaryrefslogtreecommitdiff
path: root/src/database/row.hpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2018-04-13 23:35:06 +0200
committerlouiz’ <louiz@louiz.org>2018-04-13 23:35:06 +0200
commit4bd7b6981bb49dd4111c908aaa34c34f677171f4 (patch)
tree918347adb112c04455e23fcad06626e5635b6ad4 /src/database/row.hpp
parentde8267fa3f4f4e1d61bcf35fb36c6664f520a385 (diff)
downloadbiboumi-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/row.hpp')
-rw-r--r--src/database/row.hpp49
1 files changed, 0 insertions, 49 deletions
diff --git a/src/database/row.hpp b/src/database/row.hpp
index 3703ff7..27caf43 100644
--- a/src/database/row.hpp
+++ b/src/database/row.hpp
@@ -1,9 +1,5 @@
#pragma once
-#include <database/insert_query.hpp>
-#include <database/update_query.hpp>
-#include <logger/logger.hpp>
-
#include <utils/is_one_of.hpp>
#include <type_traits>
@@ -29,52 +25,7 @@ struct Row
return col.value;
}
- template <bool Coucou=true>
- void save(std::unique_ptr<DatabaseEngine>& db, typename std::enable_if<!is_one_of<Id, T...> && Coucou>::type* = nullptr)
- {
- this->insert(*db);
- }
-
- template <bool Coucou=true>
- void save(std::unique_ptr<DatabaseEngine>& db, typename std::enable_if<is_one_of<Id, T...> && Coucou>::type* = nullptr)
- {
- const Id& id = std::get<Id>(this->columns);
- if (id.value == Id::unset_value)
- {
- this->insert(*db);
- if (db->last_inserted_rowid >= 0)
- std::get<Id>(this->columns).value = static_cast<Id::real_type>(db->last_inserted_rowid);
- }
- else
- this->update(*db);
- }
-
- private:
- template <bool Coucou=true>
- void insert(DatabaseEngine& db, typename std::enable_if<is_one_of<Id, T...> && Coucou>::type* = nullptr)
- {
- InsertQuery query(this->table_name, this->columns);
- // Ugly workaround for non portable stuff
- query.body += db.get_returning_id_sql_string(Id::name);
- query.execute(db, this->columns);
- }
-
- template <bool Coucou=true>
- void insert(DatabaseEngine& db, typename std::enable_if<!is_one_of<Id, T...> && Coucou>::type* = nullptr)
- {
- InsertQuery query(this->table_name, this->columns);
- query.execute(db, this->columns);
- }
-
- void update(DatabaseEngine& db)
- {
- UpdateQuery query(this->table_name, this->columns);
-
- query.execute(db, this->columns);
- }
-
public:
std::tuple<T...> columns;
std::string table_name;
-
};