refactor
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2024-10-08 17:50:57 -05:00
parent b84202a689
commit d144101a7e
5 changed files with 18 additions and 30 deletions

View File

@ -57,6 +57,15 @@ struct db_comp_data_t final {
std::string op_type; std::string op_type;
}; };
struct db_context_t {
db_context_t(sqlite3 &db3_, std::string table_name_)
: db3(db3_), table_name(std::move(table_name_)) {}
sqlite3 &db3;
std::string table_name;
db3_stmt_t stmt{nullptr};
};
class db_column final { class db_column final {
public: public:
db_column() noexcept = default; db_column() noexcept = default;

View File

@ -29,19 +29,13 @@
namespace repertory::db { namespace repertory::db {
class db_delete final { class db_delete final {
public: public:
struct context final { struct context final : db_context_t {
using w_t = db_where_t<context, db_delete>;
context(sqlite3 &db3_, std::string table_name_) context(sqlite3 &db3_, std::string table_name_)
: db3(db3_), table_name(std::move(table_name_)) {} : db_context_t(db3_, table_name_) {}
using w_t = db_where_t<context, db_delete>;
sqlite3 &db3;
std::string table_name;
std::optional<w_t> where; std::optional<w_t> where;
std::vector<db_types_t> where_values; std::vector<db_types_t> where_values;
db3_stmt_t stmt{nullptr};
}; };
using row = db_row<context>; using row = db_row<context>;

View File

@ -27,16 +27,12 @@
namespace repertory::db { namespace repertory::db {
class db_insert final { class db_insert final {
public: public:
struct context final { struct context final : db_context_t {
context(sqlite3 &db3_, std::string table_name_) context(sqlite3 &db3_, std::string table_name_)
: db3(db3_), table_name(std::move(table_name_)) {} : db_context_t(db3_, table_name_) {}
sqlite3 &db3;
std::string 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{};
db3_stmt_t stmt{nullptr};
}; };
using row = db_row<context>; using row = db_row<context>;

View File

@ -29,23 +29,17 @@
namespace repertory::db { namespace repertory::db {
class db_select final { class db_select final {
public: public:
struct context final { struct context final : db_context_t {
context(sqlite3 &db3_, std::string table_name_) context(sqlite3 &db3_, std::string table_name_)
: db3(db3_), table_name(std::move(table_name_)) {} : db_context_t(db3_, table_name_) {}
using w_t = db_where_with_limit_t<context, db_select>; using w_t = db_where_with_limit_t<context, db_select>;
sqlite3 &db3;
std::string table_name;
std::vector<std::string> columns{}; std::vector<std::string> columns{};
std::map<std::string, std::string> count_columns{}; std::map<std::string, std::string> count_columns{};
std::optional<std::int32_t> limit; std::optional<std::int32_t> limit;
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;
db3_stmt_t stmt{nullptr};
}; };
using row = db_row<context>; using row = db_row<context>;

View File

@ -29,21 +29,16 @@
namespace repertory::db { namespace repertory::db {
class db_update final { class db_update final {
public: public:
struct context final { struct context final : db_context_t {
context(sqlite3 &db3_, std::string table_name_) context(sqlite3 &db3_, std::string table_name_)
: db3(db3_), table_name(std::move(table_name_)) {} : db_context_t(db3_, table_name_) {}
using w_t = db_where_with_limit_t<context, db_update>; using w_t = db_where_with_limit_t<context, db_update>;
sqlite3 &db3;
std::string table_name;
std::map<std::string, db_types_t> column_values{}; std::map<std::string, db_types_t> column_values{};
std::optional<std::int32_t> limit; std::optional<std::int32_t> limit;
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;
db3_stmt_t stmt{nullptr};
}; };
using row = db_row<context>; using row = db_row<context>;