updated build system

This commit is contained in:
2024-10-10 15:07:46 -05:00
parent 1f4872769d
commit ba2850ea21
6 changed files with 141 additions and 22 deletions

View File

@ -24,6 +24,19 @@
#if defined(PROJECT_ENABLE_SQLITE)
namespace repertory::utils::db::sqlite {
void db_delete::context::clear() {
where.reset();
where_values.clear();
}
db_delete::context::db_delete_op_t::auto dump() const -> std::string {
return db_delete{ctx}.dump();
}
db_delete::context::db_delete_op_t::auto go() const -> db_result<context> {
return db_delete{ctx}.go();
}
auto db_delete::dump() const -> std::string {
std::stringstream query;
query << "DELETE FROM \"" << context_->table_name << "\"";

View File

@ -24,6 +24,42 @@
#if defined(PROJECT_ENABLE_SQLITE)
namespace repertory::utils::db::sqlite {
void db_select::context::clear() {
columns.clear();
count_columns.clear();
limit.reset();
order_by.reset();
where.reset();
where_values.clear();
}
db_select::context::db_select_op_t::auto dump() const -> std::string {
return db_select{ctx}.dump();
}
db_select::context::db_select_op_t::auto go() const -> db_result<context> {
return db_select{ctx}.go();
}
db_select::context::db_select_op_t::auto
group_by(std::string column_name) -> db_select::context::db_select_op_t {
db_select{ctx}.group_by(column_name);
return *this;
}
db_select::context::db_select_op_t::auto
limit(std::int32_t value) -> db_select::context::db_select_op_t {
db_select{ctx}.limit(value);
return *this;
}
auto db_select::context::db_select_op_t::order_by(std::string column_name,
bool ascending)
-> db_select::context::db_select_op_t {
db_select{ctx}.order_by(column_name, ascending);
return *this;
}
auto db_select::column(std::string column_name) -> db_select & {
context_->columns.push_back(column_name);
return *this;
@ -70,6 +106,17 @@ auto db_select::dump() const -> std::string {
query << " WHERE " << context_->where->dump(idx);
}
if (not context_->group_by.empty()) {
query << " GROUP BY ";
for (std::size_t idx = 0U; idx < context_->group_by.size(); idx++) {
if (idx > 0U) {
group << ", ";
}
query << "\"" << context_->group_by.at(idx) << "\"";
}
}
if (context_->order_by.has_value()) {
query << " ORDER BY \"" << context_->order_by.value().first << "\" ";
query << (context_->order_by.value().second ? "ASC" : "DESC");
@ -127,6 +174,11 @@ auto db_select::group(context::w_t::group_func_t func) -> context::w_t::wn_t {
return context_->where->group(std::move(func));
}
auto db_select::group_by(std::string column_name) -> db_select & {
context_->group_by.emplace_back(std::move(column_name));
return *this;
}
auto db_select::limit(std::int32_t value) -> db_select & {
context_->limit = value;
return *this;

View File

@ -24,6 +24,35 @@
#if defined(PROJECT_ENABLE_SQLITE)
namespace repertory::utils::db::sqlite {
void db_update::context::clear() {
column_values.clear();
limit.reset();
order_by.reset();
where.reset();
where_values.clear();
}
db_update::context::db_update_op_t::auto dump() const -> std::string {
return db_update{ctx}.dump();
}
db_update::context::db_update_op_t::auto go() const -> db_result<context> {
return db_update{ctx}.go();
}
db_update::context::db_update_op_t::auto
limit(std::int32_t value) -> db_update::context::db_update_op_t {
db_update{ctx}.limit(value);
return *this;
}
auto db_update::context::db_update_op_t::order_by(std::string column_name,
bool ascending)
-> db_update::context::db_update_op_t {
db_update{ctx}.order_by(column_name, ascending);
return *this;
}
auto db_update::column_value(std::string column_name,
db_types_t value) -> db_update & {
context_->column_values[column_name] = value;