updated build system
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
parent
3c97c2d953
commit
284e2a3ead
7
.nvimrc
7
.nvimrc
@ -18,14 +18,14 @@ if vim.env.NV_DARCULA_ENABLE_DAP then
|
|||||||
|
|
||||||
local externalConsole = gos.is_windows
|
local externalConsole = gos.is_windows
|
||||||
local type = "cppdbg"
|
local type = "cppdbg"
|
||||||
local cwd = gpath.create_path("./build")
|
local cwd = gpath.create_path("./dist/debug/shared/linux/x86_64/repertory/")
|
||||||
dap.configurations.cpp = {
|
dap.configurations.cpp = {
|
||||||
{
|
{
|
||||||
name = "Mount",
|
name = "Mount",
|
||||||
type = type,
|
type = type,
|
||||||
request = "launch",
|
request = "launch",
|
||||||
program = function()
|
program = function()
|
||||||
return gpath.create_path(cwd, "repertory")
|
return gpath.create_path(cwd, "bin/repertory")
|
||||||
end,
|
end,
|
||||||
cwd = cwd,
|
cwd = cwd,
|
||||||
stopAtEntry = true,
|
stopAtEntry = true,
|
||||||
@ -36,8 +36,9 @@ if vim.env.NV_DARCULA_ENABLE_DAP then
|
|||||||
type = type,
|
type = type,
|
||||||
request = "launch",
|
request = "launch",
|
||||||
program = function()
|
program = function()
|
||||||
return gpath.create_path(cwd, "repertory_tests")
|
return gpath.create_path(cwd, "bin/repertory_test")
|
||||||
end,
|
end,
|
||||||
|
args={"--gtest_filter=utils_db*"},
|
||||||
cwd = cwd,
|
cwd = cwd,
|
||||||
stopAtEntry = true,
|
stopAtEntry = true,
|
||||||
externalConsole=externalConsole,
|
externalConsole=externalConsole,
|
||||||
|
@ -57,10 +57,10 @@ struct db_comp_data_t final {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct db_context_t {
|
struct db_context_t {
|
||||||
db_context_t(sqlite3 &db3_, std::string table_name_)
|
db_context_t(sqlite3 *db3_, std::string table_name_)
|
||||||
: db3(db3_), table_name(std::move(table_name_)) {}
|
: db3(db3_), table_name(std::move(table_name_)) {}
|
||||||
|
|
||||||
sqlite3 &db3;
|
sqlite3 *db3{};
|
||||||
std::string table_name;
|
std::string table_name;
|
||||||
|
|
||||||
db3_stmt_t stmt;
|
db3_stmt_t stmt;
|
||||||
|
@ -39,13 +39,14 @@ public:
|
|||||||
[[nodiscard]] auto go() const -> db_result<context>;
|
[[nodiscard]] auto go() const -> db_result<context>;
|
||||||
};
|
};
|
||||||
|
|
||||||
context(sqlite3 &db3_, std::string table_name_)
|
context(sqlite3 *db3_, std::string table_name_)
|
||||||
: db_context_t(db3_, table_name_) {}
|
: db_context_t(db3_, table_name_) {}
|
||||||
|
|
||||||
using w_t = db_where_t<context, db_delete_op_t>;
|
using w_t = db_where_t<context, db_delete_op_t>;
|
||||||
|
|
||||||
std::optional<w_t> where;
|
std::optional<w_t> where;
|
||||||
std::vector<db_types_t> where_values;
|
std::vector<db_types_t> where_values;
|
||||||
|
std::map<std::size_t, std::vector<w_t::action_t>> actions;
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
};
|
};
|
||||||
@ -54,7 +55,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
db_delete(sqlite3 &db3, std::string table_name)
|
db_delete(sqlite3 &db3, std::string table_name)
|
||||||
: context_(std::make_shared<context>(db3, table_name)) {}
|
: context_(std::make_shared<context>(&db3, table_name)) {}
|
||||||
|
|
||||||
db_delete(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}
|
db_delete(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}
|
||||||
|
|
||||||
|
@ -29,11 +29,11 @@ namespace repertory::utils::db::sqlite {
|
|||||||
class db_insert final {
|
class db_insert final {
|
||||||
public:
|
public:
|
||||||
struct context final : db_context_t {
|
struct context final : db_context_t {
|
||||||
context(sqlite3 &db3_, std::string table_name_)
|
context(sqlite3 *db3_, std::string table_name_)
|
||||||
: db_context_t(db3_, table_name_) {}
|
: db_context_t(db3_, table_name_) {}
|
||||||
|
|
||||||
bool or_replace{false};
|
bool or_replace{false};
|
||||||
std::map<std::string, db_types_t> values{};
|
std::map<std::string, db_types_t> values;
|
||||||
|
|
||||||
void clear() { values.clear(); }
|
void clear() { values.clear(); }
|
||||||
};
|
};
|
||||||
@ -42,7 +42,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
db_insert(sqlite3 &db3, std::string table_name)
|
db_insert(sqlite3 &db3, std::string table_name)
|
||||||
: context_(std::make_shared<context>(db3, table_name)) {}
|
: context_(std::make_shared<context>(&db3, table_name)) {}
|
||||||
|
|
||||||
db_insert(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}
|
db_insert(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
bool ascending) -> db_select_op_t;
|
bool ascending) -> db_select_op_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
context(sqlite3 &db3_, std::string table_name_)
|
context(sqlite3 *db3_, std::string table_name_)
|
||||||
: db_context_t(db3_, table_name_) {}
|
: db_context_t(db3_, table_name_) {}
|
||||||
|
|
||||||
using w_t = db_where_t<context, db_select_op_t>;
|
using w_t = db_where_t<context, db_select_op_t>;
|
||||||
@ -59,6 +59,7 @@ public:
|
|||||||
std::optional<std::pair<std::string, bool>> order_by;
|
std::optional<std::pair<std::string, bool>> order_by;
|
||||||
std::optional<w_t> where;
|
std::optional<w_t> where;
|
||||||
std::vector<db_types_t> where_values;
|
std::vector<db_types_t> where_values;
|
||||||
|
std::map<std::size_t, std::vector<w_t::action_t>> actions;
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
};
|
};
|
||||||
@ -67,7 +68,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
db_select(sqlite3 &db3, std::string table_name)
|
db_select(sqlite3 &db3, std::string table_name)
|
||||||
: context_(std::make_shared<context>(db3, table_name)) {}
|
: context_(std::make_shared<context>(&db3, table_name)) {}
|
||||||
|
|
||||||
db_select(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}
|
db_select(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ namespace repertory::utils::db::sqlite {
|
|||||||
class db_update final {
|
class db_update final {
|
||||||
public:
|
public:
|
||||||
struct context final : db_context_t {
|
struct context final : db_context_t {
|
||||||
context(sqlite3 &db3_, std::string table_name_)
|
context(sqlite3 *db3_, std::string table_name_)
|
||||||
: db_context_t(db3_, table_name_) {}
|
: db_context_t(db3_, table_name_) {}
|
||||||
|
|
||||||
struct db_update_op_t final {
|
struct db_update_op_t final {
|
||||||
@ -54,6 +54,7 @@ public:
|
|||||||
std::optional<std::pair<std::string, bool>> order_by;
|
std::optional<std::pair<std::string, bool>> order_by;
|
||||||
std::optional<w_t> where;
|
std::optional<w_t> where;
|
||||||
std::vector<db_types_t> where_values;
|
std::vector<db_types_t> where_values;
|
||||||
|
std::map<std::size_t, std::vector<w_t::action_t>> actions;
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
};
|
};
|
||||||
@ -62,7 +63,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
db_update(sqlite3 &db3, std::string table_name)
|
db_update(sqlite3 &db3, std::string table_name)
|
||||||
: context_(std::make_shared<context>(db3, table_name)) {}
|
: context_(std::make_shared<context>(&db3, table_name)) {}
|
||||||
|
|
||||||
db_update(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}
|
db_update(std::shared_ptr<context> ctx) : context_(std::move(ctx)) {}
|
||||||
|
|
||||||
|
@ -29,14 +29,14 @@ namespace repertory::utils::db::sqlite {
|
|||||||
template <typename cn_t, typename ctx_t, typename op_t, typename w_t,
|
template <typename cn_t, typename ctx_t, typename op_t, typename w_t,
|
||||||
typename wn_t>
|
typename wn_t>
|
||||||
struct db_next_t final {
|
struct db_next_t final {
|
||||||
|
std::size_t action_idx{};
|
||||||
std::shared_ptr<ctx_t> ctx;
|
std::shared_ptr<ctx_t> ctx;
|
||||||
w_t *owner;
|
|
||||||
std::string action;
|
std::string action;
|
||||||
|
|
||||||
using group_func_t = std::function<void(w_t &)>;
|
using group_func_t = std::function<void(w_t &)>;
|
||||||
|
|
||||||
[[nodiscard]] auto where(std::string column_name) -> cn_t {
|
[[nodiscard]] auto where(std::string column_name) -> cn_t {
|
||||||
return get_next().where(column_name);
|
return w_t{action_idx, ctx}.where(column_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
|
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
|
||||||
@ -45,18 +45,10 @@ struct db_next_t final {
|
|||||||
return ctx->where->dump(idx);
|
return ctx->where->dump(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto get_next() -> w_t & {
|
|
||||||
return *std::prev(owner->sub_actions.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_next() const -> const w_t & {
|
|
||||||
return *std::prev(owner->sub_actions.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] auto go() const -> auto { return op_t{ctx}.go(); }
|
[[nodiscard]] auto go() const -> auto { return op_t{ctx}.go(); }
|
||||||
|
|
||||||
[[nodiscard]] auto group(group_func_t func) -> wn_t {
|
[[nodiscard]] auto group(group_func_t func) -> wn_t {
|
||||||
return get_next().group(std::move(func));
|
return w_t{action_idx, ctx}.group(std::move(func));
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto op() -> op_t {
|
[[nodiscard]] auto op() -> op_t {
|
||||||
@ -68,23 +60,20 @@ struct db_next_t final {
|
|||||||
|
|
||||||
template <typename cn_t, typename ctx_t, typename op_t, typename w_t>
|
template <typename cn_t, typename ctx_t, typename op_t, typename w_t>
|
||||||
struct db_where_next_t final {
|
struct db_where_next_t final {
|
||||||
|
std::size_t action_idx{};
|
||||||
std::shared_ptr<ctx_t> ctx;
|
std::shared_ptr<ctx_t> ctx;
|
||||||
w_t *owner;
|
|
||||||
|
|
||||||
using n_t = db_next_t<cn_t, ctx_t, op_t, w_t, db_where_next_t>;
|
using n_t = db_next_t<cn_t, ctx_t, op_t, w_t, db_where_next_t>;
|
||||||
|
|
||||||
[[nodiscard]] auto and_() -> n_t {
|
[[nodiscard]] auto and_() -> n_t {
|
||||||
owner->actions.emplace_back(n_t{
|
n_t next{
|
||||||
|
action_idx,
|
||||||
ctx,
|
ctx,
|
||||||
owner,
|
|
||||||
"AND",
|
"AND",
|
||||||
});
|
};
|
||||||
|
|
||||||
owner->sub_actions.emplace_back(w_t{
|
ctx->actions[action_idx].emplace_back(next);
|
||||||
ctx,
|
return next;
|
||||||
});
|
|
||||||
|
|
||||||
return std::get<n_t>(*std::prev(owner->actions.end()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
|
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
|
||||||
@ -102,30 +91,27 @@ struct db_where_next_t final {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto or_() -> n_t {
|
[[nodiscard]] auto or_() -> n_t {
|
||||||
owner->actions.emplace_back(n_t{
|
n_t next{
|
||||||
|
action_idx,
|
||||||
ctx,
|
ctx,
|
||||||
owner,
|
|
||||||
"OR",
|
"OR",
|
||||||
});
|
};
|
||||||
|
|
||||||
owner->sub_actions.emplace_back(w_t{
|
ctx->actions[action_idx].emplace_back(next);
|
||||||
ctx,
|
return next;
|
||||||
});
|
|
||||||
|
|
||||||
return std::get<n_t>(*std::prev(owner->actions.end()));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ctx_t, typename op_t, typename w_t>
|
template <typename ctx_t, typename op_t, typename w_t>
|
||||||
struct db_comp_next_t final {
|
struct db_comp_next_t final {
|
||||||
|
std::size_t action_idx{};
|
||||||
std::shared_ptr<ctx_t> ctx;
|
std::shared_ptr<ctx_t> ctx;
|
||||||
w_t *owner;
|
|
||||||
std::string column_name;
|
std::string column_name;
|
||||||
|
|
||||||
using wn_t = db_where_next_t<db_comp_next_t, ctx_t, op_t, w_t>;
|
using wn_t = db_where_next_t<db_comp_next_t, ctx_t, op_t, w_t>;
|
||||||
|
|
||||||
[[nodiscard]] auto create(std::string operation, db_types_t value) {
|
[[nodiscard]] auto create(std::string operation, db_types_t value) {
|
||||||
owner->actions.emplace_back(db_comp_data_t{
|
ctx->actions[action_idx].emplace_back(db_comp_data_t{
|
||||||
column_name,
|
column_name,
|
||||||
operation,
|
operation,
|
||||||
});
|
});
|
||||||
@ -133,8 +119,8 @@ struct db_comp_next_t final {
|
|||||||
ctx->where_values.push_back(value);
|
ctx->where_values.push_back(value);
|
||||||
|
|
||||||
return wn_t{
|
return wn_t{
|
||||||
|
action_idx,
|
||||||
ctx,
|
ctx,
|
||||||
owner,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,6 +140,7 @@ struct db_comp_next_t final {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename ctx_t, typename op_t> struct db_where_t final {
|
template <typename ctx_t, typename op_t> struct db_where_t final {
|
||||||
|
std::size_t action_idx{0U};
|
||||||
std::shared_ptr<ctx_t> ctx;
|
std::shared_ptr<ctx_t> ctx;
|
||||||
|
|
||||||
using cn_t = db_comp_next_t<ctx_t, op_t, db_where_t>;
|
using cn_t = db_comp_next_t<ctx_t, op_t, db_where_t>;
|
||||||
@ -164,25 +151,21 @@ template <typename ctx_t, typename op_t> struct db_where_t final {
|
|||||||
|
|
||||||
using action_t = std::variant<db_comp_data_t, n_t, db_where_t>;
|
using action_t = std::variant<db_comp_data_t, n_t, db_where_t>;
|
||||||
|
|
||||||
std::vector<action_t> actions{};
|
|
||||||
std::vector<db_where_t> sub_actions{};
|
|
||||||
|
|
||||||
[[nodiscard]] static auto dump(std::int32_t &idx,
|
[[nodiscard]] static auto dump(std::int32_t &idx,
|
||||||
auto &&data) -> std::string {
|
auto &&actions) -> std::string {
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
|
|
||||||
for (auto &&action : data.actions) {
|
for (auto &&action : actions) {
|
||||||
std::visit(overloaded{
|
std::visit(overloaded{
|
||||||
[&idx, &stream](const db_comp_data_t &comp) {
|
[&idx, &stream](const db_comp_data_t &comp) {
|
||||||
stream << '"' << comp.column_name << '"' << comp.op_type
|
stream << '"' << comp.column_name << '"' << comp.op_type
|
||||||
<< '?' + std::to_string(++idx);
|
<< '?' + std::to_string(++idx);
|
||||||
},
|
},
|
||||||
[&idx, &stream](const n_t &next) {
|
[&idx, &stream](const n_t &next) {
|
||||||
stream << ' ' << next.action << ' '
|
stream << ' ' << next.action << ' ';
|
||||||
<< dump(idx, next.get_next());
|
|
||||||
},
|
},
|
||||||
[&idx, &stream](const db_where_t &where) {
|
[&idx, &stream](const db_where_t &where) {
|
||||||
stream << '(' << dump(idx, where) << ')';
|
stream << '(' << dump(idx, where.get_actions()) << ')';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
action);
|
action);
|
||||||
@ -194,24 +177,37 @@ template <typename ctx_t, typename op_t> struct db_where_t final {
|
|||||||
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
|
[[nodiscard]] auto dump() const -> std::string { return op_t{ctx}.dump(); }
|
||||||
|
|
||||||
[[nodiscard]] auto dump(std::int32_t &idx) const -> std::string {
|
[[nodiscard]] auto dump(std::int32_t &idx) const -> std::string {
|
||||||
return dump(idx, *this);
|
return dump(idx, ctx->actions[action_idx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_actions() -> auto & {
|
||||||
|
return ctx->actions[action_idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_actions() const -> const auto & {
|
||||||
|
return ctx->actions[action_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto group(group_func_t func) -> wn_t {
|
[[nodiscard]] auto group(group_func_t func) -> wn_t {
|
||||||
db_where_t where{ctx};
|
ctx->actions[action_idx];
|
||||||
|
|
||||||
|
db_where_t where{ctx->actions.size(), ctx};
|
||||||
func(where);
|
func(where);
|
||||||
|
|
||||||
actions.emplace_back(std::move(where));
|
ctx->actions[action_idx].emplace_back(where);
|
||||||
|
|
||||||
return wn_t{
|
return wn_t{
|
||||||
|
action_idx,
|
||||||
ctx,
|
ctx,
|
||||||
this,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto where(std::string column_name) -> cn_t {
|
[[nodiscard]] auto where(std::string column_name) -> cn_t {
|
||||||
|
ctx->actions[action_idx];
|
||||||
|
|
||||||
return cn_t{
|
return cn_t{
|
||||||
|
action_idx,
|
||||||
ctx,
|
ctx,
|
||||||
this,
|
|
||||||
column_name,
|
column_name,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,8 @@ auto db_delete::dump() const -> std::string {
|
|||||||
auto db_delete::go() const -> db_result<context> {
|
auto db_delete::go() const -> db_result<context> {
|
||||||
sqlite3_stmt *stmt_ptr{nullptr};
|
sqlite3_stmt *stmt_ptr{nullptr};
|
||||||
auto query_str = dump();
|
auto query_str = dump();
|
||||||
auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1,
|
auto res = sqlite3_prepare_v2(context_->db3, query_str.c_str(), -1, &stmt_ptr,
|
||||||
&stmt_ptr, nullptr);
|
nullptr);
|
||||||
context_->stmt = db3_stmt_t{
|
context_->stmt = db3_stmt_t{
|
||||||
stmt_ptr,
|
stmt_ptr,
|
||||||
sqlite3_statement_deleter(),
|
sqlite3_statement_deleter(),
|
||||||
@ -88,7 +88,7 @@ auto db_delete::go() const -> db_result<context> {
|
|||||||
|
|
||||||
auto db_delete::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
auto db_delete::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
||||||
if (not context_->where.has_value()) {
|
if (not context_->where.has_value()) {
|
||||||
context_->where = context::w_t{context_};
|
context_->where = context::w_t{0U, context_};
|
||||||
}
|
}
|
||||||
|
|
||||||
return context_->where->group(std::move(func));
|
return context_->where->group(std::move(func));
|
||||||
@ -96,7 +96,7 @@ auto db_delete::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
|||||||
|
|
||||||
auto db_delete::where(std::string column_name) const -> context::w_t::cn_t {
|
auto db_delete::where(std::string column_name) const -> context::w_t::cn_t {
|
||||||
if (not context_->where.has_value()) {
|
if (not context_->where.has_value()) {
|
||||||
context_->where = context::w_t{context_};
|
context_->where = context::w_t{0U, context_};
|
||||||
}
|
}
|
||||||
|
|
||||||
return context_->where->where(column_name);
|
return context_->where->where(column_name);
|
||||||
|
@ -62,8 +62,8 @@ auto db_insert::dump() const -> std::string {
|
|||||||
auto db_insert::go() const -> db_result<context> {
|
auto db_insert::go() const -> db_result<context> {
|
||||||
sqlite3_stmt *stmt_ptr{nullptr};
|
sqlite3_stmt *stmt_ptr{nullptr};
|
||||||
auto query_str = dump();
|
auto query_str = dump();
|
||||||
auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1,
|
auto res = sqlite3_prepare_v2(context_->db3, query_str.c_str(), -1, &stmt_ptr,
|
||||||
&stmt_ptr, nullptr);
|
nullptr);
|
||||||
context_->stmt = db3_stmt_t{
|
context_->stmt = db3_stmt_t{
|
||||||
stmt_ptr,
|
stmt_ptr,
|
||||||
sqlite3_statement_deleter(),
|
sqlite3_statement_deleter(),
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace repertory::utils::db::sqlite {
|
namespace repertory::utils::db::sqlite {
|
||||||
void db_select::context::clear() {
|
void db_select::context::clear() {
|
||||||
|
std::cout << "clear" << std::endl;
|
||||||
columns.clear();
|
columns.clear();
|
||||||
count_columns.clear();
|
count_columns.clear();
|
||||||
limit.reset();
|
limit.reset();
|
||||||
@ -134,8 +135,8 @@ auto db_select::dump() const -> std::string {
|
|||||||
auto db_select::go() const -> db_result<context> {
|
auto db_select::go() const -> db_result<context> {
|
||||||
sqlite3_stmt *stmt_ptr{nullptr};
|
sqlite3_stmt *stmt_ptr{nullptr};
|
||||||
auto query_str = dump();
|
auto query_str = dump();
|
||||||
auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1,
|
auto res = sqlite3_prepare_v2(context_->db3, query_str.c_str(), -1, &stmt_ptr,
|
||||||
&stmt_ptr, nullptr);
|
nullptr);
|
||||||
context_->stmt = db3_stmt_t{
|
context_->stmt = db3_stmt_t{
|
||||||
stmt_ptr,
|
stmt_ptr,
|
||||||
sqlite3_statement_deleter(),
|
sqlite3_statement_deleter(),
|
||||||
@ -168,7 +169,7 @@ auto db_select::go() const -> db_result<context> {
|
|||||||
|
|
||||||
auto db_select::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
auto db_select::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
||||||
if (not context_->where.has_value()) {
|
if (not context_->where.has_value()) {
|
||||||
context_->where = context::w_t{context_};
|
context_->where = context::w_t{0U, context_};
|
||||||
}
|
}
|
||||||
|
|
||||||
return context_->where->group(std::move(func));
|
return context_->where->group(std::move(func));
|
||||||
@ -192,7 +193,7 @@ auto db_select::order_by(std::string column_name,
|
|||||||
|
|
||||||
auto db_select::where(std::string column_name) const -> context::w_t::cn_t {
|
auto db_select::where(std::string column_name) const -> context::w_t::cn_t {
|
||||||
if (not context_->where.has_value()) {
|
if (not context_->where.has_value()) {
|
||||||
context_->where = context::w_t{context_};
|
context_->where = context::w_t{0U, context_};
|
||||||
}
|
}
|
||||||
|
|
||||||
return context_->where->where(column_name);
|
return context_->where->where(column_name);
|
||||||
|
@ -95,8 +95,8 @@ auto db_update::dump() const -> std::string {
|
|||||||
auto db_update::go() const -> db_result<context> {
|
auto db_update::go() const -> db_result<context> {
|
||||||
sqlite3_stmt *stmt_ptr{nullptr};
|
sqlite3_stmt *stmt_ptr{nullptr};
|
||||||
auto query_str = dump();
|
auto query_str = dump();
|
||||||
auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1,
|
auto res = sqlite3_prepare_v2(context_->db3, query_str.c_str(), -1, &stmt_ptr,
|
||||||
&stmt_ptr, nullptr);
|
nullptr);
|
||||||
context_->stmt = db3_stmt_t{
|
context_->stmt = db3_stmt_t{
|
||||||
stmt_ptr,
|
stmt_ptr,
|
||||||
sqlite3_statement_deleter(),
|
sqlite3_statement_deleter(),
|
||||||
@ -157,7 +157,7 @@ auto db_update::go() const -> db_result<context> {
|
|||||||
|
|
||||||
auto db_update::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
auto db_update::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
|
||||||
if (not context_->where.has_value()) {
|
if (not context_->where.has_value()) {
|
||||||
context_->where = context::w_t{context_};
|
context_->where = context::w_t{0U, context_};
|
||||||
}
|
}
|
||||||
|
|
||||||
return context_->where->group(std::move(func));
|
return context_->where->group(std::move(func));
|
||||||
@ -176,7 +176,7 @@ auto db_update::order_by(std::string column_name,
|
|||||||
|
|
||||||
auto db_update::where(std::string column_name) const -> context::w_t::cn_t {
|
auto db_update::where(std::string column_name) const -> context::w_t::cn_t {
|
||||||
if (not context_->where.has_value()) {
|
if (not context_->where.has_value()) {
|
||||||
context_->where = context::w_t{context_};
|
context_->where = context::w_t{0U, context_};
|
||||||
}
|
}
|
||||||
|
|
||||||
return context_->where->where(column_name);
|
return context_->where->where(column_name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user