Skip to content

Commit

Permalink
Fix error on execute raw that did not insert null values
Browse files Browse the repository at this point in the history
  • Loading branch information
ospfranco committed Mar 11, 2024
1 parent 82e60be commit 11dd02f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 25 deletions.
11 changes: 2 additions & 9 deletions cpp/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
16 changes: 16 additions & 0 deletions cpp/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
#include <memory>
#include <variant>

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<uint8_t> data;
size_t size;
Expand Down
16 changes: 0 additions & 16 deletions cpp/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 11dd02f

Please sign in to comment.