Skip to content

Commit

Permalink
Fix Prepared Statement execution in libsql
Browse files Browse the repository at this point in the history
  • Loading branch information
ospfranco committed Dec 16, 2024
1 parent 0fa9f73 commit 8745181
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions cpp/PreparedStatementHostObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ jsi::Value PreparedStatementHostObject::get(jsi::Runtime &rt,
std::vector<DumbHostObject> results;
std::shared_ptr<std::vector<SmartHostObject>> metadata =
std::make_shared<std::vector<SmartHostObject>>();
try {
#ifdef OP_SQLITE_USE_LIBSQL
auto status = opsqlite_libsql_execute_prepared_statement(
_name, _stmt, &results, metadata);
auto status = opsqlite_libsql_execute_prepared_statement(
_name, _stmt, &results, metadata);
#else
try {
auto status = opsqlite_execute_prepared_statement(
_db, _stmt, &results, metadata);
#endif
invoker->invokeAsync(
[&rt, status = std::move(status),
results =
Expand All @@ -81,7 +82,6 @@ jsi::Value PreparedStatementHostObject::get(jsi::Runtime &rt,
reject->asObject(rt).asFunction(rt).call(rt, error);
});
}
#endif
};

_thread_pool->queueWork(task);
Expand Down
7 changes: 3 additions & 4 deletions cpp/PreparedStatementHostObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ class PreparedStatementHostObject : public jsi::HostObject {
std::shared_ptr<react::CallInvoker> js_call_invoker,
std::shared_ptr<ThreadPool> thread_pool)
: _name(name), _stmt(stmt), _js_call_invoker(js_call_invoker),
_thread_pool(thread_pool){};
_thread_pool(thread_pool) {};
#else
PreparedStatementHostObject(
sqlite3 *db,
std::string name, sqlite3_stmt *stmt,
sqlite3 *db, std::string name, sqlite3_stmt *stmt,
std::shared_ptr<react::CallInvoker> js_call_invoker,
std::shared_ptr<ThreadPool> thread_pool)
: _db(db), _name(name), _stmt(stmt), _js_call_invoker(js_call_invoker),
_thread_pool(thread_pool){};
_thread_pool(thread_pool) {};
#endif
virtual ~PreparedStatementHostObject();

Expand Down

0 comments on commit 8745181

Please sign in to comment.