You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: replace better-sqlite3 with bun:sqlite for schema cache and SQLite driver (#323)
* fix: replace `better-sqlite3` with `bun:sqlite` for schema cache and SQLite driver
`better-sqlite3` is a native addon that doesn't work on Bun ("not yet supported").
This broke `schema_index`, `schema_search`, `schema_cache_status`, and the SQLite
driver for all users on the released CLI binary.
Switch to `bun:sqlite` which is built into the Bun runtime — zero-install, no
native compilation, same synchronous API. The storage layer (`db.ts`) already
uses this pattern successfully.
Changes:
- `schema/cache.ts`: direct `bun:sqlite` import, sync `create()`/`createInMemory()`
- `drivers/sqlite.ts`: `bun:sqlite` import, fix PRAGMA+LIMIT syntax error
- Remove `better-sqlite3` from optional deps, peer deps, build externals, types
- Update driver docs and E2E tests (SQLite tests no longer need skip guards)
Closes#314
* test: add adversarial schema cache and SQLite driver tests
34 new tests covering:
- Upgrade path from `better-sqlite3` (legacy DB files opened by `bun:sqlite`)
- Corrupted/truncated/zero-byte database files
- SQL injection resistance via search queries (7 injection vectors + null bytes)
- Unicode and special character identifiers in schema/table/column names
- Large dataset stress (1000 tables x 10 columns)
- Re-indexing data replacement and multi-warehouse isolation
- Connector failure modes (listSchemas/listTables/describeTable errors)
- Search edge cases (empty, stop words, long query, case insensitivity, FQN)
- `listColumns` with limits and unknown warehouses
- File-based cache persistence across close/reopen
- Singleton lifecycle (getCache/resetCache)
- PRAGMA LIMIT syntax fix verification
* fix: address code review findings — readonly bug, transaction wrapping, tests
Fixes from 6-model consensus code review:
1. **CRITICAL** — SQLite driver `readonly` + `create: true` bug: gate `create`
and WAL pragma on `!readonly` so readonly connections don't silently open
read-write or crash on PRAGMA WAL.
2. **MAJOR** — Wrap `indexWarehouse` inserts in `db.transaction()` per-table
to avoid per-statement disk fsyncs (~200x slowdown for large warehouses).
3. **MAJOR** — Fix no-op parent directory test (was creating dir before testing).
Add 3 readonly connection tests (read existing, reject writes, refuse create).
4. **MINOR** — Extend `idx_columns_table` covering index to include
`column_name` for `listColumns()` ORDER BY.
0 commit comments