Skip to content

fix: enable SQLite RTree by default - #425

Merged
chrispader merged 3 commits into
mainfrom
@chrispader/fix/enable-rtree
Oct 1, 2026
Merged

chrispader merged 3 commits into
mainfrom
@chrispader/fix/enable-rtree

Conversation

@chrispader

Copy link
Copy Markdown
Member

Databases containing R*Tree tables fail with no such module: rtree when the bundled SQLite engine lacks the module. This can also block ordinary table renames when a view references an R*Tree table. This PR enables rtree and rtree_i32 by default and adds nitroSQLite.enableRTree so apps can omit them from a native build.

The original commit from #318 retains Trần Đình Huy's authorship. The follow-up adds persisted-database migration tests for both modules, verifies the default and disabled native configurations, and documents index maintenance, coordinate precision, locking, and the system-SQLite exception. Setting enableRTree to false omits the macro, because defining SQLITE_ENABLE_RTREE=0 still enables the module.

Reproduction

In a default native build, create this schema:

CREATE TABLE Item (id INTEGER PRIMARY KEY);
CREATE VIRTUAL TABLE SpatialIndex USING rtree(id, minX, maxX, minY, maxY);
INSERT INTO Item VALUES (1);
INSERT INTO SpatialIndex VALUES (1, 10, 20, 30, 40);
CREATE VIEW SpatialItems AS SELECT Item.id FROM Item JOIN SpatialIndex USING (id);

Close and reopen the database, then run:

ALTER TABLE Item RENAME TO RenamedItem;
ALTER TABLE SpatialIndex RENAME TO RenamedSpatialIndex;
SELECT id FROM SpatialItems;

Both renames should succeed and the view should return id = 1. Repeat with rtree_i32. The native probes passed locally against bundled SQLite, including the opt-out build where creating an R*Tree table reports no such module: rtree. The iOS and Android harness suites will verify the app integration in CI.

Fixes #218

@vercel

vercel Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-native-nitro-sqlite Ready Ready Preview Oct 1, 2026 10:37am UTC

Request Review

@chrispader
chrispader merged commit d51cd54 into main Oct 1, 2026
14 checks passed

This branch was successfully deployed

1 active deployment
Preview — 557ee6f0 Deployed Oct 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RTREE module is not activated by default

2 participants