From 31044c664e6f9a45344e7551ca467dafb08afda4 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Sat, 14 Dec 2024 10:15:44 +0100 Subject: [PATCH] Close connection on invalidate/destroy --- cpp/DBHostObject.cpp | 14 ++++++++++---- example/src/App.tsx | 10 +++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/cpp/DBHostObject.cpp b/cpp/DBHostObject.cpp index 2e29a95..b6feeb9 100644 --- a/cpp/DBHostObject.cpp +++ b/cpp/DBHostObject.cpp @@ -32,8 +32,8 @@ void DBHostObject::flush_pending_reactive_queries( std::shared_ptr> metadata = std::make_shared>(); - auto status = opsqlite_execute_prepared_statement(db, query->stmt, - &results, metadata); + auto status = opsqlite_execute_prepared_statement(db, query->stmt, &results, + metadata); if (status.type == SQLiteError) { invoker->invokeAsync( @@ -892,8 +892,14 @@ void DBHostObject::set(jsi::Runtime &rt, const jsi::PropNameID &name, throw std::runtime_error("You cannot write to this object!"); } -void DBHostObject::invalidate() { invalidated = true; } +void DBHostObject::invalidate() { + invalidated = true; + opsqlite_close(db); +} -DBHostObject::~DBHostObject() { invalidated = true; } +DBHostObject::~DBHostObject() { + invalidated = true; + opsqlite_close(db); +} } // namespace opsqlite diff --git a/example/src/App.tsx b/example/src/App.tsx index b29e57b..c78c1b8 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -39,13 +39,13 @@ export default function App() { useEffect(() => { runTests( queriesTests, - // dbSetupTests, - // blobTests, + dbSetupTests, + blobTests, // registerHooksTests, - // preparedStatementsTests, - // constantsTests, + preparedStatementsTests, + constantsTests, // reactiveTests, - // tokenizerTests, + tokenizerTests, ) .then(results => { setServerResults(results as any);