Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-Unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

- [Sync] Columns set while creating a record (`collection.create()` builder) are now recorded in its `_changed` field. When a pull contains a record with the same id as a locally created, not yet pushed one, conflicts are now resolved per column (locally set columns win) instead of the remote version winning. A custom `conflictResolver` receives this per-column result as `resolved`. `_changed` is also included in pushed `created` records; it's reset when the record is marked as synced
- Updated better-sqlite3 to 11.9.1
- [Android] [JSI] [Windows] Updated the bundled SQLite from 3.46.0 to 3.54.1. Its source is now part of the package (`native/sqlite`) instead of the `@nozbe/sqlite` dependency. On Windows, `sqlite3_uwp.h` replaces the two desktop-only file APIs SQLite 3.54 still calls in Windows Store builds
- [Sync] With `_unsafeBatchPerCollection`, pulled changes are now committed in batches one after another (each prepared right before it is committed) instead of all at once, so a failed batch leaves the following ones untouched. Observers are notified once per pull instead of once per table and batch
- `database.experimentalBatchNotifications()` now merges all changes made within it into one notification (one call per `experimentalSubscribe` subscriber, one emission per changed collection) instead of replaying one notification per batch

Expand Down
2 changes: 1 addition & 1 deletion docs-website/docs/docs/Advanced/ProTips.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ hide_title: true
This usually only matters if you use raw SQL to use new SQLite versions:

- On iOS, we use whatever SQLite version is bundled with the OS. [Here's a table of iOS version - SQLite version matches](https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS))
- On Android in JSI mode, we use SQLite bundled with WatermelonDB. See `@nozbe/sqlite` NPM dependency version to see which SQLite version is bundled.
- On Android in JSI mode, we use SQLite bundled with WatermelonDB. See `native/sqlite/README.md` for the bundled SQLite version.
- On Android NOT in JSI mode, we use the SQLite bundled with the OS

BTW: We're happy to accept contributions so that you can choose custom version or build of SQLite in all modes and on all platforms, but it needs to be opt-in (this adds to build time and binary size and most people don't need this)
Expand Down
10 changes: 4 additions & 6 deletions native/android-jsi/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ cmake_minimum_required(VERSION 3.4.1)
# execute_process (COMMAND ln "-s" "src" "../../../../../node_modules/react-native/third-party/double-conversion-1.1.6/double-conversion")

# NOTE: This may need to be bumped sometimes to force CMake caches to clear
set(WMELON_JSI_BUMP 4)
set(WMELON_JSI_BUMP 5)

# -------------------------------------------------
# Figure out where node_modules is
# (surely there's a better way to do this)
# This has to work with standard RN project, Nozbe's unusual folder structure and internal Watermelon tester

get_filename_component(_nativeTesterPath "../../../../../node_modules/@nozbe/sqlite/" REALPATH)
get_filename_component(_nativeTesterPath "../../../../../node_modules/@nozbe/simdjson/" REALPATH)
get_filename_component(_nozbePath "../../../../../../../../../native/node_modules/react-native/ReactCommon/jsi/jsi/" REALPATH)

if(EXISTS "${_nativeTesterPath}")
Expand All @@ -33,11 +33,9 @@ endif()
# Header search paths
# FIXME: <simdjson/simdjson.h> should work…

set(SQLITE_VERSION sqlite-amalgamation-3460000)

include_directories(
../../../../shared
${NODE_MODULES_PATH_WM}/@nozbe/sqlite/${SQLITE_VERSION}/
../../../../sqlite
${NODE_MODULES_PATH_WM}/@nozbe/simdjson/src/
${NODE_MODULES_PATH_RN}/react-native/React
${NODE_MODULES_PATH_RN}/react-native/React/Base
Expand Down Expand Up @@ -74,7 +72,7 @@ file(GLOB SHARED_SRC_FILES ../../../../shared/*.cpp)

add_library(watermelondb-jsi SHARED
# vendor files
${NODE_MODULES_PATH_WM}/@nozbe/sqlite/${SQLITE_VERSION}/sqlite3.c
../../../../sqlite/sqlite3.c
${NODE_MODULES_PATH_WM}/@nozbe/simdjson/src/simdjson.cpp
# our sources
${ANDROID_JSI_SRC_FILES}
Expand Down
9 changes: 9 additions & 0 deletions native/sqlite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SQLite

Unmodified [SQLite amalgamation](https://sqlite.org/amalgamation.html), compiled into the Android JSI library (`native/android-jsi/src/main/cpp/CMakeLists.txt`) and the Windows library (`native/windows/WatermelonDB/WatermelonDB.vcxproj`). iOS and the non-JSI Android bridge use the system SQLite.

SQLite 3.54 still calls the desktop-only `CreateFileW` and `AreFileApisANSI` in Windows Store builds ([forum thread](https://sqlite.org/forum/info/7a30926e9010465f2974247686959a59e9bd4728be4642fcd638adc909796e7b)). The Windows project force-includes `native/windows/WatermelonDB/sqlite3_uwp.h` into `sqlite3.c`, which replaces them the way SQLite 3.46 did, so the SQLite source stays unmodified. When updating, check whether it's still needed.

Version: 3.54.1, from `https://www.sqlite.org/2026/sqlite-amalgamation-3540100.zip` (SHA3-256 `92281c86e2957f9b9305890f9ac04204caa7b677cc868dc326d942689df28e30`, as listed on https://www.sqlite.org/download.html).

To update, download the new amalgamation zip, check its SHA3-256 against the download page, replace `sqlite3.c`, `sqlite3.h` and `sqlite3ext.h`, and update this file.
Loading
Loading