Commit 37ec95f
authored
perf(db): migrate Repository read queries to NativeDatabase rusqlite (6.14) (#671)
* perf(db): migrate Repository read queries to NativeDatabase rusqlite (6.14)
Implement all 40 Repository read methods as Rust napi-rs methods on
NativeDatabase so every query runs via rusqlite when the native engine
is available. openRepo() now returns NativeRepository (delegating to
NativeDatabase.openReadonly) with automatic fallback to SqliteRepository.
Rust side: read_types.rs defines 14 napi return-type structs,
read_queries.rs implements 40 query methods including BFS for
getClassHierarchy and dynamic SQL for triage/fan-in queries.
TypeScript side: NativeRepository maps napi camelCase rows back to
the snake_case field names the Repository interface expects.
* fix: make line fields optional in three Native row types (#671)
The nodes table allows NULL for line, but these three Rust structs
declared line as non-optional i32. Any node with a NULL line (e.g.
file-kind nodes) would trigger a rusqlite type-mismatch error. Change
to Option<i32> in Rust and number | null in TypeScript, with ?? 0
fallback in the converter functions to match existing Repository
interface contracts.
* fix: re-throw DbError and guard ndb handle in openRepo (#671)
Re-throw DbError (e.g. DB not found) instead of silently falling back
to better-sqlite3, which would produce a misleading debug message.
Also wrap the ndb setup block in try/catch to close the handle if an
exception occurs after openReadonly, preventing resource leaks.
* fix: distinguish table-not-found from I/O errors in table checks (#671)
has_cfg_tables, has_embeddings, and has_dataflow_table previously caught
all rusqlite errors and returned false. Now only SqliteFailure (and
QueryReturnedNoRows for embeddings) map to false — genuine I/O or
connection errors propagate as napi errors.1 parent 497f984 commit 37ec95f
8 files changed
Lines changed: 2002 additions & 3 deletions
File tree
- crates/codegraph-core/src
- src
- db
- repository
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
668 | 668 | | |
669 | 669 | | |
670 | 670 | | |
671 | | - | |
| 671 | + | |
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
| |||
0 commit comments