From 11dd02f53bbfa091520aa3bc6e5bca3be1a0f3bf Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Mon, 11 Mar 2024 22:03:20 +0100 Subject: [PATCH] Fix error on execute raw that did not insert null values --- cpp/bridge.cpp | 11 ++--------- cpp/types.h | 16 ++++++++++++++++ cpp/utils.h | 16 ---------------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/cpp/bridge.cpp b/cpp/bridge.cpp index 309acfb4..225b6209 100644 --- a/cpp/bridge.cpp +++ b/cpp/bridge.cpp @@ -80,10 +80,6 @@ BridgeResult opsqlite_attach(std::string const &mainDBName, std::string const &docPath, std::string const &databaseToAttach, std::string const &alias) { - /** - * There is no need to check if mainDBName is opened because - * sqliteExecuteLiteral will do that. - * */ std::string dbPath = get_db_path(databaseToAttach, docPath); std::string statement = "ATTACH DATABASE '" + dbPath + "' AS " + alias; @@ -104,10 +100,6 @@ BridgeResult opsqlite_attach(std::string const &mainDBName, BridgeResult opsqlite_detach(std::string const &mainDBName, std::string const &alias) { - /** - * There is no need to check if mainDBName is opened because - * sqliteExecuteLiteral will do that. - * */ std::string statement = "DETACH DATABASE " + alias; BridgeResult result = opsqlite_execute(mainDBName, statement, nullptr, nullptr, nullptr); @@ -619,7 +611,8 @@ opsqlite_execute_raw(std::string const &dbName, std::string const &query, } case SQLITE_NULL: - // Intentionally left blank + row.push_back(JSVariant(nullptr)); + break; default: row.push_back(JSVariant(nullptr)); diff --git a/cpp/types.h b/cpp/types.h index 6a185c3a..234794cd 100644 --- a/cpp/types.h +++ b/cpp/types.h @@ -4,6 +4,22 @@ #include #include +enum ResultType { SQLiteOk, SQLiteError }; + +struct BridgeResult { + ResultType type; + std::string message; + int affectedRows; + double insertId; +}; + +struct BatchResult { + ResultType type; + std::string message; + int affectedRows; + int commands; +}; + struct ArrayBuffer { std::shared_ptr data; size_t size; diff --git a/cpp/utils.h b/cpp/utils.h index b25e1782..e4e0e143 100644 --- a/cpp/utils.h +++ b/cpp/utils.h @@ -15,22 +15,6 @@ namespace opsqlite { namespace jsi = facebook::jsi; -enum ResultType { SQLiteOk, SQLiteError }; - -struct BridgeResult { - ResultType type; - std::string message; - int affectedRows; - double insertId; -}; - -struct BatchResult { - ResultType type; - std::string message; - int affectedRows; - int commands; -}; - jsi::Value toJSI(jsi::Runtime &rt, JSVariant value); JSVariant toVariant(jsi::Runtime &rt, jsi::Value const &value);