From 7fc13cd81fb41731233fb48abc3cd7fb769ea833 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Sun, 1 Dec 2024 09:24:25 +0100 Subject: [PATCH] Modify turbo.json --- cpp/DBHostObject.cpp | 10 ++++++---- example/ios/Podfile.lock | 2 +- example/package.json | 2 +- src/index.ts | 23 +++++++++++++++-------- turbo.json | 6 ++++-- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/cpp/DBHostObject.cpp b/cpp/DBHostObject.cpp index 5600543d..66b5b0b2 100644 --- a/cpp/DBHostObject.cpp +++ b/cpp/DBHostObject.cpp @@ -376,7 +376,7 @@ void DBHostObject::create_jsi_functions() { params = to_variant_vec(rt, args[1]); } #ifdef OP_SQLITE_USE_LIBSQL - auto status = opsqlite_libsql_execute(db_name, query, ¶ms); + auto status = opsqlite_libsql_execute(db_name, query, ¶ms); #else auto status = opsqlite_execute(db_name, query, ¶ms); #endif @@ -888,9 +888,11 @@ jsi::Value DBHostObject::get(jsi::Runtime &rt, const jsi::PropNameID &propNameID) { auto name = propNameID.utf8(rt); if (function_map.count(name) != 1) { - return HOSTFN(name.c_str()) { - throw std::runtime_error("[op-sqlite] Function " + name + " not implemented for current backend (libsql or sqlcipher)"); - }); + return HOSTFN(name.c_str()) { + throw std::runtime_error( + "[op-sqlite] Function " + name + + " not implemented for current backend (libsql or sqlcipher)"); + }); } return jsi::Value(rt, function_map[name]); diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 7f9537cd..94a0cee1 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1785,7 +1785,7 @@ SPEC CHECKSUMS: GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4 glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a hermes-engine: 46f1ffbf0297f4298862068dd4c274d4ac17a1fd - op-sqlite: fc35cf9d2d0ace5c5b7189e2ccadcfbb80e6e6f5 + op-sqlite: 9917e5a5747fc813e42487c0cbdd2d35eaa687bb RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648 RCTDeprecation: fde92935b3caa6cb65cbff9fbb7d3a9867ffb259 RCTRequired: 75c6cee42d21c1530a6f204ba32ff57335d19007 diff --git a/example/package.json b/example/package.json index 78c51ccd..e3a9e2c0 100644 --- a/example/package.json +++ b/example/package.json @@ -73,7 +73,7 @@ "iosSqlite": false, "fts5": true, "rtree": true, - "libsql": true, + "libsql": false, "sqliteVec": true, "tokenizers": [ "wordtokenizer", diff --git a/src/index.ts b/src/index.ts index 07beb8ae..42be8dfd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -45,6 +45,8 @@ export const { ? NativeModules.OPSQLite.getConstants() : NativeModules.OPSQLite; +type Scalar = string | number | boolean | null | ArrayBuffer | ArrayBufferView; + /** * Object returned by SQL Query executions { * insertId: Represent the auto-generated row id if applicable @@ -59,9 +61,9 @@ export type QueryResult = { insertId?: number; rowsAffected: number; res?: any[]; - rows: Array>; + rows: Array>; // An array of intermediate results, just values without column names - rawRows?: any[]; + rawRows?: Scalar[][]; columnNames?: string[]; /** * Query metadata, available only for select query results @@ -112,7 +114,7 @@ export interface FileLoadResult extends BatchQueryResult { export interface Transaction { commit: () => Promise; - execute: (query: string, params?: any[]) => Promise; + execute: (query: string, params?: Scalar[]) => Promise; rollback: () => Promise; } @@ -274,7 +276,10 @@ function enhanceDB(db: DB, options: any): DB { return result; }, - executeSync: (query: string, params?: any[] | undefined): QueryResult => { + executeSync: ( + query: string, + params?: Scalar[] | undefined + ): QueryResult => { const sanitizedParams = params?.map((p) => { if (ArrayBuffer.isView(p)) { return p.buffer; @@ -286,10 +291,11 @@ function enhanceDB(db: DB, options: any): DB { let intermediateResult = db.executeSync(query, sanitizedParams); let rows: any[] = []; for (let i = 0; i < (intermediateResult.rawRows?.length ?? 0); i++) { - let row: any = {}; + let row: Record = {}; + let rawRow = intermediateResult.rawRows![i]!; for (let j = 0; j < intermediateResult.columnNames!.length; j++) { let columnName = intermediateResult.columnNames![j]!; - let value = intermediateResult.rawRows![i][j]; + let value = rawRow[j]!; row[columnName] = value; } @@ -307,7 +313,7 @@ function enhanceDB(db: DB, options: any): DB { }, execute: async ( query: string, - params?: any[] | undefined + params?: Scalar[] | undefined ): Promise => { const sanitizedParams = params?.map((p) => { if (ArrayBuffer.isView(p)) { @@ -322,9 +328,10 @@ function enhanceDB(db: DB, options: any): DB { let rows: any[] = []; for (let i = 0; i < (intermediateResult.rawRows?.length ?? 0); i++) { let row: any = {}; + let rawRow = intermediateResult.rawRows![i]!; for (let j = 0; j < intermediateResult.columnNames!.length; j++) { let columnName = intermediateResult.columnNames![j]!; - let value = intermediateResult.rawRows![i][j]; + let value = rawRow[j]!; row[columnName] = value; } diff --git a/turbo.json b/turbo.json index e5c3058c..ebb7d00c 100644 --- a/turbo.json +++ b/turbo.json @@ -10,7 +10,8 @@ "src/tests/*.ts", "example/package.json", "example/android", - "cpp", + "cpp/*.cpp", + "cpp/*.h", "!example/android/.gradle", "!example/android/build", "!example/android/app/build" @@ -22,7 +23,8 @@ "package.json", "*.podspec", "ios", - "cpp", + "cpp/*.cpp", + "cpp/*.h", "src/*.ts", "src/tests/*.ts", "example/package.json",