~singpolyma/biboumi

fd7ee48a86aee6a6c83cc22a167717de781ed3f6 — louiz’ 6 years ago 9fa1852
Remove many log_debug from the database module
M src/database/count_query.hpp => src/database/count_query.hpp +0 -1
@@ 29,7 29,6 @@ struct CountQuery: public Query
      if (sqlite3_step(statement.get()) != SQLITE_DONE)
        log_warning("Count request returned more than one result.");

      log_debug("Returning count: ", res);
      return res;
    }
};

M src/database/insert_query.hpp => src/database/insert_query.hpp +0 -4
@@ 20,8 20,6 @@ actual_bind(Statement& statement, std::vector<std::string>& params, const std::t
  params.erase(params.begin());
  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);
  else
    log_debug("Bound (not id) [", value, "] to ", N);
}

template <int N, typename ColumnType, typename... 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)
    log_error("Failed to bind NULL to param ", N);
  else
    log_debug("Bound NULL to ", N);
}

struct InsertQuery: public Query

M src/database/query.hpp => src/database/query.hpp +1 -4
@@ 23,7 23,6 @@ struct Query
    Statement prepare(sqlite3* db)
    {
      sqlite3_stmt* stmt;
      log_debug(this->body);
      auto res = sqlite3_prepare(db, this->body.data(), static_cast<int>(this->body.size()) + 1,
                                 &stmt, nullptr);
      if (res != SQLITE_OK)


@@ 36,9 35,7 @@ struct Query
      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)
            log_debug("Failed to bind ", param, " to param ", i);
          else
            log_debug("Bound ", param, " to ", i);
            log_error("Failed to bind ", param, " to param ", i);
          i++;
        }


M src/database/row.hpp => src/database/row.hpp +0 -3
@@ 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)
{
  auto&& column = std::get<ColumnType>(columns);
  log_debug("Found an autoincrement col.");
  auto res = sqlite3_last_insert_rowid(db);
  log_debug("Value is now: ", res);
  column.value = static_cast<Id::real_type>(res);
}



@@ 63,7 61,6 @@ struct Row
      InsertQuery query(this->table_name);
      query.insert_col_names(this->columns);
      query.insert_values(this->columns);
      log_debug(query.body);

      query.execute(this->columns, db);


M src/database/table.cpp => src/database/table.cpp +0 -2
@@ 5,11 5,9 @@ std::set<std::string> get_all_columns_from_table(sqlite3* db, const std::string&
  std::set<std::string> result;
  char* errmsg;
  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 {
    constexpr int name_column = 1;
    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)
      result->insert(columns[name_column]);
    return 0;

M src/database/table.hpp => src/database/table.hpp +0 -5
@@ 2,7 2,6 @@

#include <database/select_query.hpp>
#include <database/type_to_sql.hpp>
#include <logger/logger.hpp>
#include <database/row.hpp>

#include <algorithm>


@@ 18,7 17,6 @@ void add_column_to_table(sqlite3* db, const std::string& table_name)
{
  const std::string name = ColumnType::name;
  std::string query{"ALTER TABLE " + table_name + " ADD " + ColumnType::name + " " + TypeToSQLType<typename ColumnType::real_type>::type};
  log_debug(query);
  char* error;
  const auto result = sqlite3_exec(db, query.data(), nullptr, nullptr, &error);
  if (result != SQLITE_OK)


@@ 66,11 64,8 @@ class Table
    this->add_column_create(res);
    res += ")";

    log_debug(res);

    char* error;
    const auto result = sqlite3_exec(db, res.data(), nullptr, nullptr, &error);
    log_debug("result: ", +result);
    if (result != SQLITE_OK)
      {
        log_error("Error executing query: ", error);