diff --git a/cpp/bindings.cpp b/cpp/bindings.cpp index 273fc60..1861e6e 100644 --- a/cpp/bindings.cpp +++ b/cpp/bindings.cpp @@ -91,6 +91,14 @@ void install(jsi::Runtime &rt, return false; #endif }); + + auto is_ios_embedded = HOST_STATIC_FN("isIOSEmbedded") { +#ifdef OP_SQLITE_USE_PHONE_VERSION + return true; +#else + return false; +#endif + }); auto is_libsql = HOST_STATIC_FN("isLibsql") { #ifdef OP_SQLITE_USE_LIBSQL diff --git a/example/src/tests/dbsetup.spec.ts b/example/src/tests/dbsetup.spec.ts index 2f98c52..156d7e3 100644 --- a/example/src/tests/dbsetup.spec.ts +++ b/example/src/tests/dbsetup.spec.ts @@ -2,6 +2,7 @@ import { ANDROID_DATABASE_PATH, ANDROID_EXTERNAL_FILES_PATH, IOS_LIBRARY_PATH, + isIOSEmbeeded, isLibsql, isSQLCipher, moveAssetsDatabase, @@ -37,17 +38,21 @@ export function dbSetupTests() { // db.close(); // }); - it(`Should match the sqlite expected version ${expectedVersion}`, async () => { - let db = open({ - name: 'versionTest.sqlite', - encryptionKey: 'test', - }); + // Using the embedded version, you can never be sure which version is used + // It will change from OS version to version + if (!isIOSEmbeeded()) { + it(`Should match the sqlite expected version ${expectedVersion}`, async () => { + let db = open({ + name: 'versionTest.sqlite', + encryptionKey: 'test', + }); - const res = await db.execute('select sqlite_version();'); + const res = await db.execute('select sqlite_version();'); - expect(res.rows[0]!['sqlite_version()']).to.equal(expectedVersion); - db.close(); - }); + expect(res.rows[0]!['sqlite_version()']).to.equal(expectedVersion); + db.close(); + }); + } it('Create in memory DB', async () => { let inMemoryDb = open({ diff --git a/src/index.ts b/src/index.ts index a19944d..d8c65f0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { NativeModules } from 'react-native'; +import { NativeModules, Platform } from 'react-native'; declare global { function nativeCallSyncHook(): unknown; @@ -207,6 +207,7 @@ type OPSQLiteProxy = { }) => DB; isSQLCipher: () => boolean; isLibsql: () => boolean; + isIOSEmbedded: () => boolean; }; const locks: Record< @@ -518,3 +519,11 @@ export const isSQLCipher = (): boolean => { export const isLibsql = (): boolean => { return OPSQLite.isLibsql(); }; + +export const isIOSEmbeeded = (): boolean => { + if (Platform.OS !== 'ios') { + return false; + } + + return OPSQLite.isIOSEmbedded(); +};