Skip to content
Open
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ NITRO_SQLITE_USE_PHONE_VERSION=1 npx pod-install

## Compile-time options (e.g. FTS5, Geopoly)

The bundled SQLite build enables the RTree extension by default on iOS and Android.

**iOS** — in your app’s `ios/Podfile`, in a `post_install` block:

```ruby
Expand Down
31 changes: 31 additions & 0 deletions example/tests/unit/specs/operations/execute.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,37 @@ export default function registerExecuteUnitTests() {
})
})

describe('SQLite extensions', () => {
it('creates and queries an RTree virtual table', () => {
testDb.execute('DROP TABLE IF EXISTS SpatialIndex')

try {
testDb.execute(`
CREATE VIRTUAL TABLE SpatialIndex USING rtree(
id,
minX, maxX,
minY, maxY
)
`)
testDb.execute(
'INSERT INTO SpatialIndex (id, minX, maxX, minY, maxY) VALUES (?, ?, ?, ?, ?)',
[1, 10, 20, 30, 40],
)

const result = testDb.execute(
'SELECT id, minX, maxX, minY, maxY FROM SpatialIndex WHERE minX <= ? AND maxX >= ?',
[15, 15],
)

expect(result.results).toEqual([
{ id: 1, minX: 10, maxX: 20, minY: 30, maxY: 40 },
])
} finally {
testDb.execute('DROP TABLE IF EXISTS SpatialIndex')
}
})
})

describe('ArrayBuffer support', () => {
describe('execute', () => {
it('stores and reads ArrayBuffer values from BLOB columns', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-nitro-sqlite/RNNitroSQLite.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Pod::Spec.new do |s|
'CLANG_CXX_LIBRARY' => 'libc++',
'DEFINES_MODULE' => 'YES',
"HEADER_SEARCH_PATHS" => "\"${PODS_ROOT}/RCT-Folly\"" + (nitro_sqlite_vec ? " \"#{nitro_sqlite_vec_cpp}\"" : ""),
"GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES" + (nitro_sqlite_vec ? " NITRO_SQLITE_VEC=1" : ""),
"GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES SQLITE_ENABLE_RTREE=1" + (nitro_sqlite_vec ? " NITRO_SQLITE_VEC=1" : ""),
"OTHER_CPLUSPLUSFLAGS" => folly_compiler_flags,
"OTHER_CFLAGS" => other_cflags,
}
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-nitro-sqlite/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set (CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_CXX_STANDARD 20)

add_definitions(
-DSQLITE_ENABLE_RTREE=1
${SQLITE_FLAGS}
)

Expand Down