fix
This commit is contained in:
@ -183,17 +183,7 @@ struct db_result final {
|
||||
|
||||
using row = db_row<context>;
|
||||
|
||||
db_result(sqlite3_stmt *stmt, std::int32_t res)
|
||||
: ctx_(std::make_shared<context>()), res_(res) {
|
||||
ctx_->stmt = db3_stmt_t{
|
||||
stmt,
|
||||
sqlite3_statement_deleter(),
|
||||
};
|
||||
|
||||
if (res == SQLITE_OK) {
|
||||
set_res(sqlite3_step(ctx_->stmt.get()));
|
||||
}
|
||||
}
|
||||
db_result(sqlite3_stmt *stmt, std::int32_t res);
|
||||
|
||||
db_result() = default;
|
||||
db_result(const db_result &) = default;
|
||||
@ -210,38 +200,17 @@ private:
|
||||
void set_res(std::int32_t res) const { res_ = res; }
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto ok() const -> bool {
|
||||
return res_ == SQLITE_DONE || res_ == SQLITE_ROW;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_error() const -> std::int32_t { return res_; }
|
||||
|
||||
[[nodiscard]] auto get_error_str() const -> std::string {
|
||||
auto &&err_msg = sqlite3_errstr(res_);
|
||||
return err_msg == nullptr ? std::to_string(res_) : err_msg;
|
||||
}
|
||||
[[nodiscard]] auto get_error_str() const -> std::string;
|
||||
|
||||
[[nodiscard]] auto get_row(std::optional<row> &opt_row) const -> bool {
|
||||
opt_row.reset();
|
||||
|
||||
if (not has_row()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
opt_row = db_row<context>{ctx_};
|
||||
set_res(sqlite3_step(ctx_->stmt.get()));
|
||||
return true;
|
||||
}
|
||||
[[nodiscard]] auto get_row(std::optional<row> &opt_row) const -> bool;
|
||||
|
||||
[[nodiscard]] auto has_row() const -> bool { return res_ == SQLITE_ROW; }
|
||||
|
||||
void next_row() const {
|
||||
if (not has_row()) {
|
||||
return;
|
||||
}
|
||||
void next_row() const;
|
||||
|
||||
set_res(sqlite3_step(ctx_->stmt.get()));
|
||||
}
|
||||
[[nodiscard]] auto ok() const -> bool;
|
||||
};
|
||||
} // namespace repertory::utils::db::sqlite
|
||||
|
||||
|
Reference in New Issue
Block a user