Commit fd7ee48a authored by louiz’'s avatar louiz’

Remove many log_debug from the database module

parent 9fa1852c
...@@ -29,7 +29,6 @@ struct CountQuery: public Query ...@@ -29,7 +29,6 @@ struct CountQuery: public Query
if (sqlite3_step(statement.get()) != SQLITE_DONE) if (sqlite3_step(statement.get()) != SQLITE_DONE)
log_warning("Count request returned more than one result."); log_warning("Count request returned more than one result.");
log_debug("Returning count: ", res);
return res; return res;
} }
}; };
...@@ -20,8 +20,6 @@ actual_bind(Statement& statement, std::vector<std::string>& params, const std::t ...@@ -20,8 +20,6 @@ actual_bind(Statement& statement, std::vector<std::string>& params, const std::t
params.erase(params.begin()); params.erase(params.begin());
if (sqlite3_bind_text(statement.get(), N + 1, value.data(), static_cast<int>(value.size()), SQLITE_TRANSIENT) != SQLITE_OK) if (sqlite3_bind_text(statement.get(), N + 1, value.data(), static_cast<int>(value.size()), SQLITE_TRANSIENT) != SQLITE_OK)
log_error("Failed to bind ", value, " to param ", N); log_error("Failed to bind ", value, " to param ", N);
else
log_debug("Bound (not id) [", value, "] to ", N);
} }
template <int N, typename ColumnType, typename... T> template <int N, typename ColumnType, typename... T>
...@@ -36,8 +34,6 @@ actual_bind(Statement& statement, std::vector<std::string>&, const std::tuple<T. ...@@ -36,8 +34,6 @@ actual_bind(Statement& statement, std::vector<std::string>&, const std::tuple<T.
} }
else if (sqlite3_bind_null(statement.get(), N + 1) != SQLITE_OK) else if (sqlite3_bind_null(statement.get(), N + 1) != SQLITE_OK)
log_error("Failed to bind NULL to param ", N); log_error("Failed to bind NULL to param ", N);
else
log_debug("Bound NULL to ", N);
} }
struct InsertQuery: public Query struct InsertQuery: public Query
......
...@@ -23,7 +23,6 @@ struct Query ...@@ -23,7 +23,6 @@ struct Query
Statement prepare(sqlite3* db) Statement prepare(sqlite3* db)
{ {
sqlite3_stmt* stmt; sqlite3_stmt* stmt;
log_debug(this->body);
auto res = sqlite3_prepare(db, this->body.data(), static_cast<int>(this->body.size()) + 1, auto res = sqlite3_prepare(db, this->body.data(), static_cast<int>(this->body.size()) + 1,
&stmt, nullptr); &stmt, nullptr);
if (res != SQLITE_OK) if (res != SQLITE_OK)
...@@ -36,9 +35,7 @@ struct Query ...@@ -36,9 +35,7 @@ struct Query
for (const std::string& param: this->params) for (const std::string& param: this->params)
{ {
if (sqlite3_bind_text(statement.get(), i, param.data(), static_cast<int>(param.size()), SQLITE_TRANSIENT) != SQLITE_OK) if (sqlite3_bind_text(statement.get(), i, param.data(), static_cast<int>(param.size()), SQLITE_TRANSIENT) != SQLITE_OK)
log_debug("Failed to bind ", param, " to param ", i); log_error("Failed to bind ", param, " to param ", i);
else
log_debug("Bound ", param, " to ", i);
i++; i++;
} }
......
...@@ -17,9 +17,7 @@ typename std::enable_if<std::is_same<std::decay_t<ColumnType>, Id>::value, void> ...@@ -17,9 +17,7 @@ typename std::enable_if<std::is_same<std::decay_t<ColumnType>, Id>::value, void>
update_id(std::tuple<T...>& columns, sqlite3* db) update_id(std::tuple<T...>& columns, sqlite3* db)
{ {
auto&& column = std::get<ColumnType>(columns); auto&& column = std::get<ColumnType>(columns);
log_debug("Found an autoincrement col.");
auto res = sqlite3_last_insert_rowid(db); auto res = sqlite3_last_insert_rowid(db);
log_debug("Value is now: ", res);
column.value = static_cast<Id::real_type>(res); column.value = static_cast<Id::real_type>(res);
} }
...@@ -63,7 +61,6 @@ struct Row ...@@ -63,7 +61,6 @@ struct Row
InsertQuery query(this->table_name); InsertQuery query(this->table_name);
query.insert_col_names(this->columns); query.insert_col_names(this->columns);
query.insert_values(this->columns); query.insert_values(this->columns);
log_debug(query.body);
query.execute(this->columns, db); query.execute(this->columns, db);
......
...@@ -5,11 +5,9 @@ std::set<std::string> get_all_columns_from_table(sqlite3* db, const std::string& ...@@ -5,11 +5,9 @@ std::set<std::string> get_all_columns_from_table(sqlite3* db, const std::string&
std::set<std::string> result; std::set<std::string> result;
char* errmsg; char* errmsg;
std::string query{"PRAGMA table_info(" + table_name + ")"}; std::string query{"PRAGMA table_info(" + table_name + ")"};
log_debug(query);
int res = sqlite3_exec(db, query.data(), [](void* param, int columns_nb, char** columns, char**) -> int { int res = sqlite3_exec(db, query.data(), [](void* param, int columns_nb, char** columns, char**) -> int {
constexpr int name_column = 1; constexpr int name_column = 1;
std::set<std::string>* result = static_cast<std::set<std::string>*>(param); std::set<std::string>* result = static_cast<std::set<std::string>*>(param);
log_debug("Table has column ", columns[name_column]);
if (name_column < columns_nb) if (name_column < columns_nb)
result->insert(columns[name_column]); result->insert(columns[name_column]);
return 0; return 0;
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#include <database/select_query.hpp> #include <database/select_query.hpp>
#include <database/type_to_sql.hpp> #include <database/type_to_sql.hpp>
#include <logger/logger.hpp>
#include <database/row.hpp> #include <database/row.hpp>
#include <algorithm> #include <algorithm>
...@@ -18,7 +17,6 @@ void add_column_to_table(sqlite3* db, const std::string& table_name) ...@@ -18,7 +17,6 @@ void add_column_to_table(sqlite3* db, const std::string& table_name)
{ {
const std::string name = ColumnType::name; const std::string name = ColumnType::name;
std::string query{"ALTER TABLE " + table_name + " ADD " + ColumnType::name + " " + TypeToSQLType<typename ColumnType::real_type>::type}; std::string query{"ALTER TABLE " + table_name + " ADD " + ColumnType::name + " " + TypeToSQLType<typename ColumnType::real_type>::type};
log_debug(query);
char* error; char* error;
const auto result = sqlite3_exec(db, query.data(), nullptr, nullptr, &error); const auto result = sqlite3_exec(db, query.data(), nullptr, nullptr, &error);
if (result != SQLITE_OK) if (result != SQLITE_OK)
...@@ -66,11 +64,8 @@ class Table ...@@ -66,11 +64,8 @@ class Table
this->add_column_create(res); this->add_column_create(res);
res += ")"; res += ")";
log_debug(res);
char* error; char* error;
const auto result = sqlite3_exec(db, res.data(), nullptr, nullptr, &error); const auto result = sqlite3_exec(db, res.data(), nullptr, nullptr, &error);
log_debug("result: ", +result);
if (result != SQLITE_OK) if (result != SQLITE_OK)
{ {
log_error("Error executing query: ", error); log_error("Error executing query: ", error);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment