diff --git a/repertory/repertory_test/src/database_test.cpp b/repertory/repertory_test/src/database_test.cpp index e55a9bad..2a649b16 100644 --- a/repertory/repertory_test/src/database_test.cpp +++ b/repertory/repertory_test/src/database_test.cpp @@ -37,14 +37,30 @@ public: void SetUp() override { event_system::instance().start(); - sqlite3 *db3_ptr{nullptr}; - auto res = sqlite3_open_v2( - utils::path::combine(test::get_test_input_dir(), {"test.db3"}).c_str(), - &db3_ptr, SQLITE_OPEN_READWRITE, nullptr); - ASSERT_EQ(SQLITE_OK, res); - ASSERT_TRUE(db3_ptr != nullptr); + { + sqlite3 *db3_ptr{nullptr}; + auto res = + sqlite3_open_v2(":memory:", &db3_ptr, SQLITE_OPEN_READWRITE, nullptr); + ASSERT_EQ(SQLITE_OK, res); + 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 { diff --git a/repertory/repertory_test/test_config/test.db3 b/repertory/repertory_test/test_config/test.db3 deleted file mode 100644 index 1f8fd12b..00000000 Binary files a/repertory/repertory_test/test_config/test.db3 and /dev/null differ diff --git a/support/src/utils/db/sqlite/db_delete.cpp b/support/src/utils/db/sqlite/db_delete.cpp index 7b5a0718..fad23bcc 100644 --- a/support/src/utils/db/sqlite/db_delete.cpp +++ b/support/src/utils/db/sqlite/db_delete.cpp @@ -48,11 +48,9 @@ auto db_delete::go() const -> db_result { auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1, &stmt_ptr, nullptr); 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}; } + context_->stmt.reset(stmt_ptr); for (std::int32_t idx = 0; @@ -69,9 +67,6 @@ auto db_delete::go() const -> db_result { }, context_->where_values.at(static_cast(idx))); 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}; } } diff --git a/support/src/utils/db/sqlite/db_insert.cpp b/support/src/utils/db/sqlite/db_insert.cpp index 1978c7cc..b7d2b854 100644 --- a/support/src/utils/db/sqlite/db_insert.cpp +++ b/support/src/utils/db/sqlite/db_insert.cpp @@ -69,11 +69,9 @@ auto db_insert::go() const -> db_result { auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1, &stmt_ptr, nullptr); if (res != SQLITE_OK) { - utils::error::raise_error(function_name, "failed to prepare|" + - std::to_string(res) + '|' + - sqlite3_errstr(res)); return {context_, res}; } + context_->stmt.reset(stmt_ptr); for (std::int32_t idx = 0; @@ -90,9 +88,6 @@ auto db_insert::go() const -> db_result { }, std::next(context_->values.begin(), idx)->second); if (res != SQLITE_OK) { - utils::error::raise_error(function_name, "failed to bind|" + - std::to_string(res) + '|' + - sqlite3_errstr(res)); return {context_, res}; } } diff --git a/support/src/utils/db/sqlite/db_select.cpp b/support/src/utils/db/sqlite/db_select.cpp index 2b34ee7e..3a40dcd1 100644 --- a/support/src/utils/db/sqlite/db_select.cpp +++ b/support/src/utils/db/sqlite/db_select.cpp @@ -94,11 +94,9 @@ auto db_select::go() const -> db_result { auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1, &stmt_ptr, nullptr); 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}; } + context_->stmt.reset(stmt_ptr); for (std::int32_t idx = 0; @@ -115,9 +113,6 @@ auto db_select::go() const -> db_result { }, context_->where_values.at(static_cast(idx))); 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}; } } diff --git a/support/src/utils/db/sqlite/db_update.cpp b/support/src/utils/db/sqlite/db_update.cpp index f939f60d..1cc316a9 100644 --- a/support/src/utils/db/sqlite/db_update.cpp +++ b/support/src/utils/db/sqlite/db_update.cpp @@ -73,9 +73,6 @@ auto db_update::go() const -> db_result { auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1, &stmt_ptr, nullptr); 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}; } context_->stmt.reset(stmt_ptr); @@ -94,9 +91,6 @@ auto db_update::go() const -> db_result { }, std::next(context_->column_values.begin(), idx)->second); if (res != SQLITE_OK) { - utils::error::raise_error(function_name, "failed to bind|" + - std::to_string(res) + '|' + - sqlite3_errstr(res)); return {context_, res}; } } @@ -125,9 +119,6 @@ auto db_update::go() const -> db_result { }, context_->where_values.at(static_cast(idx))); 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}; } }