EXPECT_TRUE(ret);
}
+TEST_F(DatabaseTest, test_reuse_result2) {
+ tizen_base::Database db(TEST_DB, SQLITE_OPEN_READWRITE);
+ auto q = tizen_base::Database::Sql(Q_INSERT);
+ auto r = db.Prepare(q);
+ EXPECT_TRUE(r);
+
+ q.Reset()
+ .Bind("gugu")
+ .Bind(5678)
+ .Bind(9.216)
+ .Bind(std::nullopt);
+ bool ret = db.Exec(q, r);
+ EXPECT_TRUE(ret);
+
+ q.Reset()
+ .Bind("gg")
+ .Bind(7777)
+ .Bind(9.216)
+ .Bind(std::nullopt);
+ ret = db.Exec(q, r);
+ EXPECT_TRUE(ret);
+}
+
TEST_F(DatabaseTest, test_set_empty_string_as_null) {
tizen_base::Database db(TEST_DB, SQLITE_OPEN_READWRITE);
auto q = tizen_base::Database::Sql(Q_INSERT)
return TransactionGuard(db_);
}
+ Result Prepare(const Sql& sql) const {
+ if (!db_)
+ throw DbException("Not opened");
+
+ sqlite3_stmt* stmt = nullptr;
+ int r = sqlite3_prepare_v2(db_, sql.GetQuery().c_str(),
+ -1, &stmt, nullptr);
+ if (r != SQLITE_OK)
+ return { nullptr, nullptr, "", true };
+ return { stmt, db_, sql.GetQuery(), false };
+ }
+
Result Exec(const Sql& sql) const {
if (!db_)
throw DbException("Not opened");