fix
This commit is contained in:
parent
8541e292cd
commit
14ebdab034
@ -37,16 +37,32 @@ public:
|
|||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
event_system::instance().start();
|
event_system::instance().start();
|
||||||
|
|
||||||
|
{
|
||||||
sqlite3 *db3_ptr{nullptr};
|
sqlite3 *db3_ptr{nullptr};
|
||||||
auto res = sqlite3_open_v2(
|
auto res =
|
||||||
utils::path::combine(test::get_test_input_dir(), {"test.db3"}).c_str(),
|
sqlite3_open_v2(":memory:", &db3_ptr, SQLITE_OPEN_READWRITE, nullptr);
|
||||||
&db3_ptr, SQLITE_OPEN_READWRITE, nullptr);
|
|
||||||
ASSERT_EQ(SQLITE_OK, res);
|
ASSERT_EQ(SQLITE_OK, res);
|
||||||
ASSERT_TRUE(db3_ptr != nullptr);
|
ASSERT_TRUE(db3_ptr != nullptr);
|
||||||
|
|
||||||
db3.reset(db3_ptr);
|
db3.reset(db3_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string sql{
|
||||||
|
"CREATE TABLE [table] (column1 TEXT PRIMARY KEY UNIQUE "
|
||||||
|
"NOT NULL, column2 TEXT NOT NULL);",
|
||||||
|
};
|
||||||
|
|
||||||
|
db3_stmt_t db3_stmt;
|
||||||
|
{
|
||||||
|
sqlite3_stmt *stmt_ptr{};
|
||||||
|
res = sqlite3_prepare_v2(db3_ptr, sql.c_str(), -1, &stmt_ptr, nullptr);
|
||||||
|
ASSERT_EQ(SQLITE_OK, res);
|
||||||
|
db3_stmt.reset(stmt_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
res = sqlite3_step(db3_stmt.get());
|
||||||
|
ASSERT_EQ(SQLITE_DONE, res);
|
||||||
|
}
|
||||||
|
|
||||||
void TearDown() override {
|
void TearDown() override {
|
||||||
db3.reset();
|
db3.reset();
|
||||||
event_system::instance().stop();
|
event_system::instance().stop();
|
||||||
|
Binary file not shown.
@ -48,11 +48,9 @@ auto db_delete::go() const -> db_result<context> {
|
|||||||
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, nullptr);
|
&stmt_ptr, nullptr);
|
||||||
if (res != SQLITE_OK) {
|
if (res != SQLITE_OK) {
|
||||||
utils::error::raise_error(function_name,
|
|
||||||
"failed to prepare|" + std::to_string(res) + '|' +
|
|
||||||
sqlite3_errstr(res) + '|' + query_str);
|
|
||||||
return {context_, res};
|
return {context_, res};
|
||||||
}
|
}
|
||||||
|
|
||||||
context_->stmt.reset(stmt_ptr);
|
context_->stmt.reset(stmt_ptr);
|
||||||
|
|
||||||
for (std::int32_t idx = 0;
|
for (std::int32_t idx = 0;
|
||||||
@ -69,9 +67,6 @@ auto db_delete::go() const -> db_result<context> {
|
|||||||
},
|
},
|
||||||
context_->where_values.at(static_cast<std::size_t>(idx)));
|
context_->where_values.at(static_cast<std::size_t>(idx)));
|
||||||
if (res != SQLITE_OK) {
|
if (res != SQLITE_OK) {
|
||||||
utils::error::raise_error(function_name,
|
|
||||||
"failed to bind|" + std::to_string(res) + '|' +
|
|
||||||
sqlite3_errstr(res) + '|' + query_str);
|
|
||||||
return {context_, res};
|
return {context_, res};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,11 +69,9 @@ auto db_insert::go() const -> db_result<context> {
|
|||||||
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, nullptr);
|
&stmt_ptr, nullptr);
|
||||||
if (res != SQLITE_OK) {
|
if (res != SQLITE_OK) {
|
||||||
utils::error::raise_error(function_name, "failed to prepare|" +
|
|
||||||
std::to_string(res) + '|' +
|
|
||||||
sqlite3_errstr(res));
|
|
||||||
return {context_, res};
|
return {context_, res};
|
||||||
}
|
}
|
||||||
|
|
||||||
context_->stmt.reset(stmt_ptr);
|
context_->stmt.reset(stmt_ptr);
|
||||||
|
|
||||||
for (std::int32_t idx = 0;
|
for (std::int32_t idx = 0;
|
||||||
@ -90,9 +88,6 @@ auto db_insert::go() const -> db_result<context> {
|
|||||||
},
|
},
|
||||||
std::next(context_->values.begin(), idx)->second);
|
std::next(context_->values.begin(), idx)->second);
|
||||||
if (res != SQLITE_OK) {
|
if (res != SQLITE_OK) {
|
||||||
utils::error::raise_error(function_name, "failed to bind|" +
|
|
||||||
std::to_string(res) + '|' +
|
|
||||||
sqlite3_errstr(res));
|
|
||||||
return {context_, res};
|
return {context_, res};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,11 +94,9 @@ auto db_select::go() const -> db_result<context> {
|
|||||||
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, nullptr);
|
&stmt_ptr, nullptr);
|
||||||
if (res != SQLITE_OK) {
|
if (res != SQLITE_OK) {
|
||||||
utils::error::raise_error(function_name,
|
|
||||||
"failed to prepare|" + std::to_string(res) + '|' +
|
|
||||||
sqlite3_errstr(res) + '|' + query_str);
|
|
||||||
return {context_, res};
|
return {context_, res};
|
||||||
}
|
}
|
||||||
|
|
||||||
context_->stmt.reset(stmt_ptr);
|
context_->stmt.reset(stmt_ptr);
|
||||||
|
|
||||||
for (std::int32_t idx = 0;
|
for (std::int32_t idx = 0;
|
||||||
@ -115,9 +113,6 @@ auto db_select::go() const -> db_result<context> {
|
|||||||
},
|
},
|
||||||
context_->where_values.at(static_cast<std::size_t>(idx)));
|
context_->where_values.at(static_cast<std::size_t>(idx)));
|
||||||
if (res != SQLITE_OK) {
|
if (res != SQLITE_OK) {
|
||||||
utils::error::raise_error(function_name,
|
|
||||||
"failed to bind|" + std::to_string(res) + '|' +
|
|
||||||
sqlite3_errstr(res) + '|' + query_str);
|
|
||||||
return {context_, res};
|
return {context_, res};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,9 +73,6 @@ auto db_update::go() const -> db_result<context> {
|
|||||||
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, nullptr);
|
&stmt_ptr, nullptr);
|
||||||
if (res != SQLITE_OK) {
|
if (res != SQLITE_OK) {
|
||||||
utils::error::raise_error(function_name,
|
|
||||||
"failed to prepare|" + std::to_string(res) + '|' +
|
|
||||||
sqlite3_errstr(res) + '|' + query_str);
|
|
||||||
return {context_, res};
|
return {context_, res};
|
||||||
}
|
}
|
||||||
context_->stmt.reset(stmt_ptr);
|
context_->stmt.reset(stmt_ptr);
|
||||||
@ -94,9 +91,6 @@ auto db_update::go() const -> db_result<context> {
|
|||||||
},
|
},
|
||||||
std::next(context_->column_values.begin(), idx)->second);
|
std::next(context_->column_values.begin(), idx)->second);
|
||||||
if (res != SQLITE_OK) {
|
if (res != SQLITE_OK) {
|
||||||
utils::error::raise_error(function_name, "failed to bind|" +
|
|
||||||
std::to_string(res) + '|' +
|
|
||||||
sqlite3_errstr(res));
|
|
||||||
return {context_, res};
|
return {context_, res};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,9 +119,6 @@ auto db_update::go() const -> db_result<context> {
|
|||||||
},
|
},
|
||||||
context_->where_values.at(static_cast<std::size_t>(idx)));
|
context_->where_values.at(static_cast<std::size_t>(idx)));
|
||||||
if (res != SQLITE_OK) {
|
if (res != SQLITE_OK) {
|
||||||
utils::error::raise_error(function_name,
|
|
||||||
"failed to bind|" + std::to_string(res) + '|' +
|
|
||||||
sqlite3_errstr(res) + '|' + query_str);
|
|
||||||
return {context_, res};
|
return {context_, res};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user