@op-engineering/op-sqlite 6.0.1 → 6.0.2-beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/CMakeLists.txt +26 -15
- package/android/build.gradle +10 -1
- package/android/cpp-adapter.cpp +4 -0
- package/android/jniLibs/arm64-v8a/libsql_experimental.a +0 -0
- package/android/jniLibs/armeabi-v7a/libsql_experimental.a +0 -0
- package/android/jniLibs/x86/libsql_experimental.a +0 -0
- package/android/jniLibs/x86_64/libsql_experimental.a +0 -0
- package/cpp/DBHostObject.cpp +882 -0
- package/cpp/DBHostObject.h +61 -0
- package/cpp/PreparedStatementHostObject.cpp +29 -15
- package/cpp/PreparedStatementHostObject.h +18 -14
- package/cpp/bindings.cpp +24 -616
- package/cpp/bindings.h +5 -2
- package/cpp/bridge.cpp +55 -16
- package/cpp/bridge.h +5 -1
- package/cpp/libsql/bridge.cpp +629 -0
- package/cpp/libsql/bridge.h +88 -0
- package/cpp/libsql/libsql.h +133 -0
- package/cpp/sqlite3.h +0 -1
- package/cpp/types.h +5 -0
- package/cpp/utils.cpp +68 -6
- package/cpp/utils.h +5 -5
- package/ios/libsql.xcframework/Info.plist +48 -0
- package/ios/libsql.xcframework/ios-arm64/Headers/libsql.h +133 -0
- package/ios/libsql.xcframework/ios-arm64/libsql_experimental.a +0 -0
- package/ios/libsql.xcframework/ios-arm64_x86_64-simulator/Headers/libsql.h +133 -0
- package/ios/libsql.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.a +0 -0
- package/lib/commonjs/index.js +143 -153
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +141 -152
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +28 -39
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/op-sqlite.podspec +20 -3
- package/package.json +1 -1
- package/src/index.ts +203 -272
- package/cpp/sqlbatchexecutor.cpp +0 -93
- package/cpp/sqlbatchexecutor.h +0 -30
package/cpp/bindings.h
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
1
3
|
#include <ReactCommon/CallInvoker.h>
|
|
2
4
|
#include <jsi/jsi.h>
|
|
3
5
|
#include <jsi/jsilib.h>
|
|
4
6
|
|
|
5
|
-
using namespace facebook;
|
|
6
|
-
|
|
7
7
|
namespace opsqlite {
|
|
8
8
|
|
|
9
|
+
namespace jsi = facebook::jsi;
|
|
10
|
+
namespace react = facebook::react;
|
|
11
|
+
|
|
9
12
|
void install(jsi::Runtime &rt,
|
|
10
13
|
std::shared_ptr<react::CallInvoker> jsCallInvoker,
|
|
11
14
|
const char *docPath, const char *crsqlitePath);
|
package/cpp/bridge.cpp
CHANGED
|
@@ -397,13 +397,11 @@ opsqlite_execute(std::string const &dbName, std::string const &query,
|
|
|
397
397
|
|
|
398
398
|
if (statementStatus != SQLITE_OK) {
|
|
399
399
|
const char *message = sqlite3_errmsg(db);
|
|
400
|
-
return {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
". See error codes: https://www.sqlite.org/rescode.html",
|
|
406
|
-
};
|
|
400
|
+
return {.type = SQLiteError,
|
|
401
|
+
.message =
|
|
402
|
+
"[op-sqlite] SQL statement error on opsqlite_execute:\n" +
|
|
403
|
+
std::to_string(statementStatus) + " description:\n" +
|
|
404
|
+
std::string(message)};
|
|
407
405
|
}
|
|
408
406
|
|
|
409
407
|
// The statement did not fail to parse but there is nothing to do, just
|
|
@@ -529,9 +527,7 @@ opsqlite_execute(std::string const &dbName, std::string const &query,
|
|
|
529
527
|
return {.type = SQLiteError,
|
|
530
528
|
.message =
|
|
531
529
|
"[op-sqlite] SQLite error code: " + std::to_string(result) +
|
|
532
|
-
", description: " + std::string(errorMessage)
|
|
533
|
-
".\nSee SQLite error codes reference: "
|
|
534
|
-
"https://www.sqlite.org/rescode.html"};
|
|
530
|
+
", description: " + std::string(errorMessage)};
|
|
535
531
|
}
|
|
536
532
|
|
|
537
533
|
int changedRowCount = sqlite3_changes(db);
|
|
@@ -575,8 +571,7 @@ opsqlite_execute_raw(std::string const &dbName, std::string const &query,
|
|
|
575
571
|
.type = SQLiteError,
|
|
576
572
|
.message = "[op-sqlite] SQL statement error:" +
|
|
577
573
|
std::to_string(statementStatus) +
|
|
578
|
-
" description:" + std::string(message)
|
|
579
|
-
". See error codes: https://www.sqlite.org/rescode.html",
|
|
574
|
+
" description:" + std::string(message),
|
|
580
575
|
};
|
|
581
576
|
}
|
|
582
577
|
|
|
@@ -686,9 +681,7 @@ opsqlite_execute_raw(std::string const &dbName, std::string const &query,
|
|
|
686
681
|
return {.type = SQLiteError,
|
|
687
682
|
.message =
|
|
688
683
|
"[op-sqlite] SQLite error code: " + std::to_string(step) +
|
|
689
|
-
", description: " + std::string(errorMessage)
|
|
690
|
-
".\nSee SQLite error codes reference: "
|
|
691
|
-
"https://www.sqlite.org/rescode.html"};
|
|
684
|
+
", description: " + std::string(errorMessage)};
|
|
692
685
|
}
|
|
693
686
|
|
|
694
687
|
int changedRowCount = sqlite3_changes(db);
|
|
@@ -843,7 +836,8 @@ BridgeResult opsqlite_deregister_rollback_hook(std::string const &dbName) {
|
|
|
843
836
|
return {SQLiteOk};
|
|
844
837
|
}
|
|
845
838
|
|
|
846
|
-
BridgeResult opsqlite_load_extension(std::string &db_name,
|
|
839
|
+
BridgeResult opsqlite_load_extension(std::string const &db_name,
|
|
840
|
+
std::string &path,
|
|
847
841
|
std::string &entry_point) {
|
|
848
842
|
#ifdef OP_SQLITE_USE_PHONE_VERSION
|
|
849
843
|
throw std::runtime_error(
|
|
@@ -873,4 +867,49 @@ BridgeResult opsqlite_load_extension(std::string &db_name, std::string &path,
|
|
|
873
867
|
#endif
|
|
874
868
|
}
|
|
875
869
|
|
|
870
|
+
BatchResult opsqlite_execute_batch(std::string dbName,
|
|
871
|
+
std::vector<BatchArguments> *commands) {
|
|
872
|
+
size_t commandCount = commands->size();
|
|
873
|
+
if (commandCount <= 0) {
|
|
874
|
+
return BatchResult{
|
|
875
|
+
.type = SQLiteError,
|
|
876
|
+
.message = "No SQL commands provided",
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
try {
|
|
881
|
+
int affectedRows = 0;
|
|
882
|
+
opsqlite_execute(dbName, "BEGIN EXCLUSIVE TRANSACTION", nullptr, nullptr,
|
|
883
|
+
nullptr);
|
|
884
|
+
for (int i = 0; i < commandCount; i++) {
|
|
885
|
+
auto command = commands->at(i);
|
|
886
|
+
// We do not provide a datastructure to receive query data because we
|
|
887
|
+
// don't need/want to handle this results in a batch execution
|
|
888
|
+
auto result = opsqlite_execute(dbName, command.sql, command.params.get(),
|
|
889
|
+
nullptr, nullptr);
|
|
890
|
+
if (result.type == SQLiteError) {
|
|
891
|
+
opsqlite_execute(dbName, "ROLLBACK", nullptr, nullptr, nullptr);
|
|
892
|
+
return BatchResult{
|
|
893
|
+
.type = SQLiteError,
|
|
894
|
+
.message = result.message,
|
|
895
|
+
};
|
|
896
|
+
} else {
|
|
897
|
+
affectedRows += result.affectedRows;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
opsqlite_execute(dbName, "COMMIT", nullptr, nullptr, nullptr);
|
|
901
|
+
return BatchResult{
|
|
902
|
+
.type = SQLiteOk,
|
|
903
|
+
.affectedRows = affectedRows,
|
|
904
|
+
.commands = static_cast<int>(commandCount),
|
|
905
|
+
};
|
|
906
|
+
} catch (std::exception &exc) {
|
|
907
|
+
opsqlite_execute(dbName, "ROLLBACK", nullptr, nullptr, nullptr);
|
|
908
|
+
return BatchResult{
|
|
909
|
+
.type = SQLiteError,
|
|
910
|
+
.message = exc.what(),
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
876
915
|
} // namespace opsqlite
|
package/cpp/bridge.h
CHANGED
|
@@ -50,6 +50,9 @@ opsqlite_execute(std::string const &dbName, std::string const &query,
|
|
|
50
50
|
std::vector<DumbHostObject> *results,
|
|
51
51
|
std::shared_ptr<std::vector<SmartHostObject>> metadatas);
|
|
52
52
|
|
|
53
|
+
BatchResult opsqlite_execute_batch(std::string dbName,
|
|
54
|
+
std::vector<BatchArguments> *commands);
|
|
55
|
+
|
|
53
56
|
BridgeResult opsqlite_execute_raw(std::string const &dbName,
|
|
54
57
|
std::string const &query,
|
|
55
58
|
const std::vector<JSVariant> *params,
|
|
@@ -78,7 +81,8 @@ BridgeResult opsqlite_execute_prepared_statement(
|
|
|
78
81
|
std::vector<DumbHostObject> *results,
|
|
79
82
|
std::shared_ptr<std::vector<SmartHostObject>> metadatas);
|
|
80
83
|
|
|
81
|
-
BridgeResult opsqlite_load_extension(std::string &db_name,
|
|
84
|
+
BridgeResult opsqlite_load_extension(std::string const &db_name,
|
|
85
|
+
std::string &path,
|
|
82
86
|
std::string &entry_point);
|
|
83
87
|
|
|
84
88
|
} // namespace opsqlite
|