Repository navigation
[Android] Bundle SQLite 3.54.1 instead of @nozbe/sqlite 3.46.0 - #21
Conversation
The JSI build on Android compiles SQLite into the app from the @nozbe/sqlite package, which still holds SQLite 3.46.0 (June 2024). That package is an unmodified copy of the official amalgamation and has not been updated since. The amalgamation of SQLite 3.54.1, checked against the SHA3-256 on sqlite.org, now lives in native/android-jsi/sqlite and is compiled from there. The @nozbe/sqlite dependency is removed. iOS keeps using the system SQLite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Removing @nozbe/sqlite breaks clean Windows builds because the Windows project still references its sources; migrate those references to vendored SQLite or retain the dependency.
1 open issue
What changed in this PR
This PR updates WatermelonDB’s bundled Android JSI SQLite from 3.46.0 to 3.54.1 and moves its source into the repository. iOS and the non-JSI Android bridge remain unchanged.
Changes:
- Switch Android CMake to local SQLite sources, update test-app detection, and bump the cache counter.
- Remove the
@nozbe/sqlitedependency and lockfile entry. - Document the bundled version, source verification, and update procedure.
| File | Description |
|---|---|
yarn.lock |
Removes the @nozbe/sqlite lockfile entry. |
package.json |
Removes the @nozbe/sqlite dependency. |
native/android-jsi/src/main/cpp/CMakeLists.txt |
Builds local SQLite sources and updates dependency discovery. |
native/android-jsi/sqlite/sqlite3ext.h |
Adds the bundled SQLite extension API header. |
native/android-jsi/sqlite/README.md |
Records the version, checksum, source, and update steps. |
docs-website/docs/docs/Advanced/ProTips.md |
Points users to the bundled-version README. |
CHANGELOG-Unreleased.md |
Announces the Android JSI SQLite upgrade. |
Review effort: Balanced
The Windows project also compiled SQLite from @nozbe/sqlite, so removing the dependency broke it. The source moves to native/sqlite, which both the Android JSI and the Windows project build from, and the build script copies it into the package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Current SQLite selects its Windows Store code paths with SQLITE_UWP instead of SQLITE_OS_WINRT, so with 3.54.1 the project would use desktop-only APIs. Both are defined, so a project pointing WatermelonSqliteDir at an older SQLite still works. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SQLITE_UWP was introduced in SQLite 3.54.0, not right after 3.46. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Checked the Windows Store build with Microsoft's compiler: a one-off job on
So SQLite 3.54.1 does not compile for this Windows Store project in either configuration, while 3.46.0 does. MinGW reports the same. Not fixed yet; the options are being discussed. 🤖 Generated with Claude Code |
A Windows SDK build in Windows Store mode fails on CreateFileW and AreFileApisANSI, which SQLite 3.54.1 calls even with SQLITE_UWP. The Windows port is unmaintained and not built on CI, so the bundled SQLite is shared anyway, and the breakage is listed under breaking changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only 3.46.0 and 3.54.1 were checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SQLite 3.53 dropped its CreateFile2 path, and 3.54 still calls the desktop-only CreateFileW and AreFileApisANSI with SQLITE_UWP. A header force-included only into sqlite3.c routes CreateFileW to CreateFile2 with SQLite 3.46's flag mapping and makes AreFileApisANSI return true, as 3.46 did, so sqlite3.c stays unmodified. The breaking-change note goes away. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The Windows project and UWP file-API shim need maintainer validation through a full react-native-windows build and Store-sandbox database/WAL testing, as existing evidence covers only standalone compilation and desktop smoke tests.
No open issues 🎉
Review effort: Balanced

@nozbe/sqlitepackage, which holds SQLite 3.46.0 from June 2024 and hasn't been updated since. That package is an unmodified copy of SQLite's official single-file source (the "amalgamation").native/sqlite, and both builds compile it from there. The build script copies it into the package. The download was checked against the SHA3-256 hash on sqlite.org, andREADME.mdthere records the version, source and update steps.@nozbe/sqlitedependency is removed. The published package stays about 3 MB, since it now carries the source that the old dependency used to bring in.CMakeLists.txt: the build looks for its own test app by checking for@nozbe/simdjsoninstead of@nozbe/sqlite. The cache counter is bumped, so CMake builds from scratch.WatermelonDB.vcxproj:WatermelonSqliteDirnow defaults tonative/sqlite, the same wayWatermelonJsiSharedDirpoints tonative/shared. Consumers can still override it.WatermelonDB.vcxprojalso definesSQLITE_UWP. SQLite 3.53.0 dropped Windows RT support, and 3.54.0 documents-DSQLITE_UWP=1for UWP apps.SQLITE_OS_WINRTstays defined for older SQLite versions.native/windows/WatermelonDB/sqlite3_uwp.h, force-included only intosqlite3.c. SQLite 3.53 dropped itsCreateFile2path, and 3.54 still calls the desktop-onlyCreateFileWandAreFileApisANSIwithSQLITE_UWP(reported upstream in this forum thread, unfixed). In Windows Store builds, the header routesCreateFileWtoCreateFile2with SQLite 3.46's flag mapping, and makesAreFileApisANSIreturn true, as 3.46 did.sqlite3.cstays unmodified.Verification:
sqlite3.ccompiles with NDK 27.1 for arm64 at-Os.yarn buildputs the SQLite files underdist/native/sqlite, anddist/package.jsonno longer lists@nozbe/sqlite.if: false, the port is unmaintained upstream), so it was checked with one-off runs onwindows-2022(MSVC 14.44, Windows SDK 10.0.26100) in Windows Store mode (WINAPI_FAMILY=WINAPI_FAMILY_APP, asWatermelonDB.vcxprojbuilds):CreateFileWandAreFileApisANSI(run).sqlite3.ccompiles at/W4without errors or warnings. It no longer referencesCreateFileW, usesCreateFile2, and every Windows import is inWindowsApp.lib, the set Store apps may call (run).WatermelonDB.vcxproj/ react-native-windows build was not run.🤖 Generated with Claude Code