Skip to content

Commit

Permalink
Fix libsql code
Browse files Browse the repository at this point in the history
  • Loading branch information
ospfranco committed Oct 15, 2024
1 parent e556bf2 commit a2680e3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
19 changes: 11 additions & 8 deletions cpp/DBHostObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "macros.h"
#include "utils.h"
#include <iostream>
#include <utility>

namespace opsqlite {

Expand All @@ -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() {
Expand Down Expand Up @@ -124,7 +125,8 @@ DBHostObject::DBHostObject(jsi::Runtime &rt, std::string &url,
std::string &auth_token,
std::shared_ptr<react::CallInvoker> invoker,
std::shared_ptr<ThreadPool> 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) {
Expand All @@ -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);

Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"performanceMode": "2",
"iosSqlite": false,
"fts5": true,
"libsql": false,
"libsql": true,
"sqliteVec": true
}
}
2 changes: 1 addition & 1 deletion example/src/tests/dbsetup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit a2680e3

Please sign in to comment.