fix
This commit is contained in:
parent
55bcf082ec
commit
891040479b
@ -39,8 +39,6 @@ using db3_t = std::unique_ptr<sqlite3, sqlite3_deleter>;
|
||||
struct sqlite3_statement_deleter {
|
||||
void operator()(sqlite3_stmt *stmt) const {
|
||||
if (stmt != nullptr) {
|
||||
std::cout << "freeing stmt" << std::endl;
|
||||
sqlite3_reset(stmt);
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
}
|
||||
@ -181,6 +179,8 @@ template <typename ctx_t> struct db_result final {
|
||||
}
|
||||
}
|
||||
|
||||
~db_result() { context_->clear(); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<ctx_t> context_;
|
||||
mutable std::int32_t res_;
|
||||
|
@ -37,6 +37,11 @@ public:
|
||||
|
||||
std::optional<w_t> where;
|
||||
std::vector<db_types_t> where_values;
|
||||
|
||||
void clear() {
|
||||
where.reset();
|
||||
where_values.clear();
|
||||
}
|
||||
};
|
||||
|
||||
using row = db_row<context>;
|
||||
|
@ -34,6 +34,8 @@ public:
|
||||
|
||||
bool or_replace{false};
|
||||
std::map<std::string, db_types_t> values{};
|
||||
|
||||
void clear() { values.clear(); }
|
||||
};
|
||||
|
||||
using row = db_row<context>;
|
||||
|
@ -33,14 +33,24 @@ public:
|
||||
struct context final : db_context_t {
|
||||
context(sqlite3 &db3_, std::string table_name_)
|
||||
: db_context_t(db3_, table_name_) {}
|
||||
|
||||
using w_t = db_where_with_limit_t<context, db_select>;
|
||||
|
||||
std::vector<std::string> columns{};
|
||||
std::map<std::string, std::string> count_columns{};
|
||||
std::vector<std::string> columns;
|
||||
std::map<std::string, std::string> count_columns;
|
||||
std::optional<std::int32_t> limit;
|
||||
std::optional<std::pair<std::string, bool>> order_by;
|
||||
std::optional<w_t> where;
|
||||
std::vector<db_types_t> where_values;
|
||||
|
||||
void clear() {
|
||||
columns.clear();
|
||||
count_columns.clear();
|
||||
limit.reset();
|
||||
order_by.reset();
|
||||
where.reset();
|
||||
where_values.clear();
|
||||
}
|
||||
};
|
||||
|
||||
using row = db_row<context>;
|
||||
|
@ -35,11 +35,19 @@ public:
|
||||
: db_context_t(db3_, table_name_) {}
|
||||
using w_t = db_where_with_limit_t<context, db_update>;
|
||||
|
||||
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::pair<std::string, bool>> order_by;
|
||||
std::optional<w_t> where;
|
||||
std::vector<db_types_t> where_values;
|
||||
|
||||
void clear() {
|
||||
column_values.clear();
|
||||
limit.reset();
|
||||
order_by.reset();
|
||||
where.reset();
|
||||
where_values.clear();
|
||||
}
|
||||
};
|
||||
|
||||
using row = db_row<context>;
|
||||
|
@ -60,10 +60,6 @@ auto db_insert::dump() const -> std::string {
|
||||
}
|
||||
|
||||
auto db_insert::go() const -> db_result<context> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
|
||||
sqlite3_stmt *stmt_ptr{nullptr};
|
||||
auto query_str = dump();
|
||||
auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user