From a2680e33e16022448aaa30ab871353c574331b98 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Tue, 15 Oct 2024 11:52:37 +0200 Subject: [PATCH] Fix libsql code --- cpp/DBHostObject.cpp | 19 +++++++++++-------- example/ios/Podfile.lock | 4 ++-- example/package.json | 2 +- example/src/tests/dbsetup.spec.ts | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/cpp/DBHostObject.cpp b/cpp/DBHostObject.cpp index c2772b58..dfc81fe0 100644 --- a/cpp/DBHostObject.cpp +++ b/cpp/DBHostObject.cpp @@ -9,6 +9,7 @@ #include "macros.h" #include "utils.h" #include +#include namespace opsqlite { @@ -17,7 +18,7 @@ namespace react = facebook::react; #ifdef OP_SQLITE_USE_LIBSQL void DBHostObject::flush_pending_reactive_queries() { - // intentionally left blank + // intentionally left blank } #else void DBHostObject::flush_pending_reactive_queries() { @@ -124,7 +125,8 @@ DBHostObject::DBHostObject(jsi::Runtime &rt, std::string &url, std::string &auth_token, std::shared_ptr invoker, std::shared_ptr thread_pool) - : db_name(url), invoker(invoker), thread_pool(thread_pool), rt(rt) { + : db_name(url), invoker(std::move(invoker)), + thread_pool(std::move(thread_pool)), rt(rt) { BridgeResult result = opsqlite_libsql_open_remote(url, auth_token); if (result.type == SQLiteError) { @@ -140,7 +142,8 @@ DBHostObject::DBHostObject(jsi::Runtime &rt, std::string &db_name, std::string &path, std::string &url, std::string &auth_token, int sync_interval) - : db_name(db_name), invoker(invoker), thread_pool(thread_pool), rt(rt) { + : db_name(db_name), invoker(std::move(invoker)), + thread_pool(std::move(thread_pool)), rt(rt) { BridgeResult result = opsqlite_libsql_open_sync(db_name, path, url, auth_token, sync_interval); @@ -160,8 +163,8 @@ DBHostObject::DBHostObject(jsi::Runtime &rt, std::string &base_path, std::string &crsqlite_path, std::string &sqlite_vec_path, std::string &encryption_key) - : base_path(base_path), invoker(invoker), thread_pool(thread_pool), - db_name(db_name), rt(rt) { + : base_path(base_path), invoker(std::move(invoker)), + thread_pool(std::move(thread_pool)), db_name(db_name), rt(rt) { #ifdef OP_SQLITE_USE_SQLCIPHER BridgeResult result = opsqlite_open(db_name, path, crsqlite_path, @@ -273,7 +276,7 @@ void DBHostObject::create_jsi_functions() { if (!location.empty()) { if (location == ":memory:") { path = ":memory:"; - } else if (location.rfind("/", 0) == 0) { + } else if (location.rfind('/', 0) == 0) { path = location; } else { path = path + "/" + location; @@ -822,6 +825,8 @@ void DBHostObject::create_jsi_functions() { function_map["executeBatch"] = std::move(execute_batch); function_map["prepareStatement"] = std::move(prepare_statement); function_map["getDbPath"] = std::move(get_db_path); + function_map["flushPendingReactiveQueries"] = + std::move(flush_pending_reactive_queries_js); #ifdef OP_SQLITE_USE_LIBSQL function_map["sync"] = std::move(sync); #else @@ -831,8 +836,6 @@ void DBHostObject::create_jsi_functions() { function_map["rollbackHook"] = std::move(rollback_hook); function_map["loadExtension"] = std::move(load_extension); function_map["reactiveExecute"] = std::move(reactive_execute); - function_map["flushPendingReactiveQueries"] = - std::move(flush_pending_reactive_queries_js); #endif } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 2d6c9c48..723294b3 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -10,7 +10,7 @@ PODS: - hermes-engine (0.74.0): - hermes-engine/Pre-built (= 0.74.0) - hermes-engine/Pre-built (0.74.0) - - op-sqlite (9.1.3): + - op-sqlite (9.2.1): - React - React-callinvoker - React-Core @@ -1393,7 +1393,7 @@ SPEC CHECKSUMS: GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4 glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2 hermes-engine: 6eae7edb2f563ee41d7c1f91f4f2e57c26d8a5c3 - op-sqlite: efd0f6f9aa3215353b825625d4b132d5951e168e + op-sqlite: de7f4da4de0217c70e41bf0695967070ad6561d9 RCT-Folly: 045d6ecaa59d826c5736dfba0b2f4083ff8d79df RCTDeprecation: 3ca8b6c36bfb302e1895b72cfe7db0de0c92cd47 RCTRequired: 9fc183af555fd0c89a366c34c1ae70b7e03b1dc5 diff --git a/example/package.json b/example/package.json index 800d2073..cdcf34ed 100644 --- a/example/package.json +++ b/example/package.json @@ -68,7 +68,7 @@ "performanceMode": "2", "iosSqlite": false, "fts5": true, - "libsql": false, + "libsql": true, "sqliteVec": true } } diff --git a/example/src/tests/dbsetup.spec.ts b/example/src/tests/dbsetup.spec.ts index b5888bf5..e5bd1e64 100644 --- a/example/src/tests/dbsetup.spec.ts +++ b/example/src/tests/dbsetup.spec.ts @@ -14,7 +14,7 @@ import {Platform} from 'react-native'; let expect = chai.expect; const expectedVersion = isLibsql() - ? '3.46.1' + ? '3.45.1' : isSQLCipher() ? '3.46.1' : '3.46.1';