This commit is contained in:
		@@ -24,8 +24,8 @@
 | 
			
		||||
#include "utils/db/sqlite/db_insert.hpp"
 | 
			
		||||
 | 
			
		||||
namespace repertory::utils::db::sqlite {
 | 
			
		||||
auto db_insert::column_value(std::string column_name, db_types_t value)
 | 
			
		||||
    -> db_insert & {
 | 
			
		||||
auto db_insert::column_value(std::string column_name,
 | 
			
		||||
                             db_types_t value) -> db_insert & {
 | 
			
		||||
  ctx_->values[column_name] = value;
 | 
			
		||||
  return *this;
 | 
			
		||||
}
 | 
			
		||||
@@ -71,17 +71,17 @@ auto db_insert::go() const -> db_result {
 | 
			
		||||
 | 
			
		||||
  for (std::int32_t idx = 0;
 | 
			
		||||
       idx < static_cast<std::int32_t>(ctx_->values.size()); idx++) {
 | 
			
		||||
    res = std::visit(overloaded{
 | 
			
		||||
                         [this, &idx](std::int64_t data) -> std::int32_t {
 | 
			
		||||
                           return sqlite3_bind_int64(ctx_->stmt.get(), idx + 1,
 | 
			
		||||
                                                     data);
 | 
			
		||||
                         },
 | 
			
		||||
                         [this, &idx](const std::string &data) -> std::int32_t {
 | 
			
		||||
                           return sqlite3_bind_text(ctx_->stmt.get(), idx + 1,
 | 
			
		||||
                                                    data.c_str(), -1, nullptr);
 | 
			
		||||
                         },
 | 
			
		||||
                     },
 | 
			
		||||
                     std::next(ctx_->values.begin(), idx)->second);
 | 
			
		||||
    res = std::visit(
 | 
			
		||||
        overloaded{
 | 
			
		||||
            [&idx, &stmt_ptr](std::int64_t data) -> std::int32_t {
 | 
			
		||||
              return sqlite3_bind_int64(stmt_ptr, idx + 1, data);
 | 
			
		||||
            },
 | 
			
		||||
            [&idx, &stmt_ptr](const std::string &data) -> std::int32_t {
 | 
			
		||||
              return sqlite3_bind_text(stmt_ptr, idx + 1, data.c_str(), -1,
 | 
			
		||||
                                       nullptr);
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
        std::next(ctx_->values.begin(), idx)->second);
 | 
			
		||||
    if (res != SQLITE_OK) {
 | 
			
		||||
      return {stmt_ptr, res};
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -62,8 +62,8 @@ auto db_select::column(std::string column_name) -> db_select & {
 | 
			
		||||
  return *this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
auto db_select::count(std::string column_name, std::string as_column_name)
 | 
			
		||||
    -> db_select & {
 | 
			
		||||
auto db_select::count(std::string column_name,
 | 
			
		||||
                      std::string as_column_name) -> db_select & {
 | 
			
		||||
  ctx_->count_columns[column_name] = as_column_name;
 | 
			
		||||
  return *this;
 | 
			
		||||
}
 | 
			
		||||
@@ -151,12 +151,12 @@ auto db_select::go() const -> db_result {
 | 
			
		||||
       idx++) {
 | 
			
		||||
    res = std::visit(
 | 
			
		||||
        overloaded{
 | 
			
		||||
            [this, &idx](std::int64_t data) -> std::int32_t {
 | 
			
		||||
              return sqlite3_bind_int64(ctx_->stmt.get(), idx + 1, data);
 | 
			
		||||
            [&idx, &stmt_ptr](std::int64_t data) -> std::int32_t {
 | 
			
		||||
              return sqlite3_bind_int64(stmt_ptr, idx + 1, data);
 | 
			
		||||
            },
 | 
			
		||||
            [this, &idx](const std::string &data) -> std::int32_t {
 | 
			
		||||
              return sqlite3_bind_text(ctx_->stmt.get(), idx + 1, data.c_str(),
 | 
			
		||||
                                       -1, nullptr);
 | 
			
		||||
            [&idx, &stmt_ptr](const std::string &data) -> std::int32_t {
 | 
			
		||||
              return sqlite3_bind_text(stmt_ptr, idx + 1, data.c_str(), -1,
 | 
			
		||||
                                       nullptr);
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
        ctx_->where_data->values.at(static_cast<std::size_t>(idx)));
 | 
			
		||||
@@ -195,8 +195,8 @@ auto db_select::offset(std::int32_t value) -> db_select & {
 | 
			
		||||
  return *this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
auto db_select::order_by(std::string column_name, bool ascending)
 | 
			
		||||
    -> db_select & {
 | 
			
		||||
auto db_select::order_by(std::string column_name,
 | 
			
		||||
                         bool ascending) -> db_select & {
 | 
			
		||||
  ctx_->order_by = {column_name, ascending};
 | 
			
		||||
  return *this;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -45,8 +45,8 @@ auto db_update::context::db_update_op_t::order_by(std::string column_name,
 | 
			
		||||
  return *this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
auto db_update::column_value(std::string column_name, db_types_t value)
 | 
			
		||||
    -> db_update & {
 | 
			
		||||
auto db_update::column_value(std::string column_name,
 | 
			
		||||
                             db_types_t value) -> db_update & {
 | 
			
		||||
  ctx_->column_values[column_name] = value;
 | 
			
		||||
  return *this;
 | 
			
		||||
}
 | 
			
		||||
@@ -97,17 +97,17 @@ auto db_update::go() const -> db_result {
 | 
			
		||||
 | 
			
		||||
  for (std::int32_t idx = 0;
 | 
			
		||||
       idx < static_cast<std::int32_t>(ctx_->column_values.size()); idx++) {
 | 
			
		||||
    res = std::visit(overloaded{
 | 
			
		||||
                         [this, &idx](std::int64_t data) -> std::int32_t {
 | 
			
		||||
                           return sqlite3_bind_int64(ctx_->stmt.get(), idx + 1,
 | 
			
		||||
                                                     data);
 | 
			
		||||
                         },
 | 
			
		||||
                         [this, &idx](const std::string &data) -> std::int32_t {
 | 
			
		||||
                           return sqlite3_bind_text(ctx_->stmt.get(), idx + 1,
 | 
			
		||||
                                                    data.c_str(), -1, nullptr);
 | 
			
		||||
                         },
 | 
			
		||||
                     },
 | 
			
		||||
                     std::next(ctx_->column_values.begin(), idx)->second);
 | 
			
		||||
    res = std::visit(
 | 
			
		||||
        overloaded{
 | 
			
		||||
            [&stmt_ptr, &idx](std::int64_t data) -> std::int32_t {
 | 
			
		||||
              return sqlite3_bind_int64(stmt_ptr, idx + 1, data);
 | 
			
		||||
            },
 | 
			
		||||
            [&stmt_ptr, &idx](const std::string &data) -> std::int32_t {
 | 
			
		||||
              return sqlite3_bind_text(stmt_ptr, idx + 1, data.c_str(), -1,
 | 
			
		||||
                                       nullptr);
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
        std::next(ctx_->column_values.begin(), idx)->second);
 | 
			
		||||
    if (res != SQLITE_OK) {
 | 
			
		||||
      return {stmt_ptr, res};
 | 
			
		||||
    }
 | 
			
		||||
@@ -122,16 +122,16 @@ auto db_update::go() const -> db_result {
 | 
			
		||||
       idx++) {
 | 
			
		||||
    res = std::visit(
 | 
			
		||||
        overloaded{
 | 
			
		||||
            [this, &idx](std::int64_t data) -> std::int32_t {
 | 
			
		||||
            [this, &idx, &stmt_ptr](std::int64_t data) -> std::int32_t {
 | 
			
		||||
              return sqlite3_bind_int64(
 | 
			
		||||
                  ctx_->stmt.get(),
 | 
			
		||||
                  stmt_ptr,
 | 
			
		||||
                  idx + static_cast<std::int32_t>(ctx_->column_values.size()) +
 | 
			
		||||
                      1,
 | 
			
		||||
                  data);
 | 
			
		||||
            },
 | 
			
		||||
            [this, &idx](const std::string &data) -> std::int32_t {
 | 
			
		||||
            [this, &idx, &stmt_ptr](const std::string &data) -> std::int32_t {
 | 
			
		||||
              return sqlite3_bind_text(
 | 
			
		||||
                  ctx_->stmt.get(),
 | 
			
		||||
                  stmt_ptr,
 | 
			
		||||
                  idx + static_cast<std::int32_t>(ctx_->column_values.size()) +
 | 
			
		||||
                      1,
 | 
			
		||||
                  data.c_str(), -1, nullptr);
 | 
			
		||||
@@ -163,8 +163,8 @@ auto db_update::limit(std::int32_t value) -> db_update & {
 | 
			
		||||
  return *this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
auto db_update::order_by(std::string column_name, bool ascending)
 | 
			
		||||
    -> db_update & {
 | 
			
		||||
auto db_update::order_by(std::string column_name,
 | 
			
		||||
                         bool ascending) -> db_update & {
 | 
			
		||||
  ctx_->order_by = {column_name, ascending};
 | 
			
		||||
  return *this;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user