Add API to get the raw handle of DB 45/286145/2
authorjh9216.park <jh9216.park@samsung.com>
Thu, 29 Dec 2022 05:42:42 +0000 (00:42 -0500)
committerjh9216.park <jh9216.park@samsung.com>
Fri, 30 Dec 2022 06:07:38 +0000 (01:07 -0500)
- Because tizen-database does not support full set of sqlite3 API,
this method may be needed
- Make a method as 'const'

Change-Id: I1b8c3d05b298cf943b2fde07510a8cdbc70e9e03
Signed-off-by: jh9216.park <jh9216.park@samsung.com>
tests/tizen-database_unittests/src/test_database.cc
tizen-database/database.hpp

index f524af9..d949056 100644 (file)
@@ -504,3 +504,10 @@ TEST_F(DatabaseTest, test_transaction_commit) {
 
   EXPECT_EQ(ret, SQLITE_OK);
 }
+
+TEST_F(DatabaseTest, test_get_raw) {
+  tizen_base::Database db(TEST_DB, SQLITE_OPEN_READWRITE);
+  auto* db_raw = db.GetRaw();
+
+  EXPECT_NE(db_raw, nullptr);
+}
index 8425fe8..9b752f7 100644 (file)
@@ -664,7 +664,7 @@ class Database {
         r == SQLITE_DONE ? true : false };
   }
 
-  bool Exec(const Sql& sql, Result& previous_stmt) {
+  bool Exec(const Sql& sql, Result& previous_stmt) const {
     if (sql.GetQuery() != previous_stmt.GetQuery())
       throw DbException("Query is different");
 
@@ -710,6 +710,12 @@ class Database {
     }
   }
 
+  sqlite3* GetRaw() const {
+    if (!db_)
+      throw DbException("Not opened");
+    return db_;
+  }
+
  private:
   void Bind(int pos, const DbType& type, sqlite3_stmt* stmt) const {
     int r;