Commit 1b9c058
* feat: migrate SQLite connector to built-in node:sqlite (#317)
Replace better-sqlite3 with Node's built-in node:sqlite module, eliminating
native C++ compilation (node-gyp) and prebuild friction. SQLite now needs no
driver package and is always available.
API mapping:
- new Database(path, {readonly}) -> new DatabaseSync(path, {readOnly})
- db.defaultSafeIntegers(true) -> stmt.setReadBigInts(true) (per-statement,
centralized in a private prepare() helper)
- db.inTransaction -> db.isTransaction
Behavior preserved vs better-sqlite3:
- run() returns BigInt `changes` with setReadBigInts; normalized via Number()
- foreign keys default off (enableForeignKeyConstraints: false)
Build/runtime gotchas fixed:
- tsup removeNodeProtocol stripped `node:sqlite` -> `sqlite` (unresolvable);
set removeNodeProtocol: false
- node:sqlite emits ExperimentalWarning at load time; install a targeted
warning filter (suppress-experimental-warning.ts) before loading node:sqlite,
and load it via a non-hoisted lazy dynamic import() inside connect()
Other:
- drop better-sqlite3 / @types/better-sqlite3; bump engines.node to >=22.5.0
- CI run-tests Node 20 -> 22; update install/quickstart docs
- remove better-sqlite3 native-build approvals from pnpm-workspace.yaml
BREAKING CHANGE: requires Node.js >= 22.5.0
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor: consolidate SQLite introspection queries behind typed helpers
Schema introspection reads small integer flags (notnull, pk, unique) that
must be plain numbers for `=== 1` / `> 0` comparisons to work, while
executeSQL needs BigInt to preserve 64-bit user-data precision. The migration
left this split implicit and inconsistent: some methods used this.prepare()
(BigInt) and others this.db.prepare() (number), and getTableSchema was on the
wrong side — its `notnull === 1` check silently failed against BigInt.
- Add private queryAll<T>/queryOne<T> helpers for introspection (plain numbers,
centralizing the repeated `as unknown as X` casts and the not-connected guard)
- Route all introspection (getTables, getViews, tableExists, getTableIndexes,
getTableSchema) through them; getTableSchema now compares plain numbers
- Keep prepare() (BigInt) for executeSQL only, with a clarified doc comment
No behavior change for covered cases; corrects the latent NOT NULL detection
for non-PK columns in getTableSchema. All SQLite tests pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs: state Node.js >= 22.5.0 requirement for the npm method
The engine floor now applies to running DBHub via npm/npx (node:sqlite),
not just SQLite. Note it in the README quick-start and dev sections, and add
a callout in installation.mdx clarifying Docker users don't need local Node.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor: install node:sqlite warning hook lazily, not at startup
The experimental-warning suppression was a top-level side-effect import, so
loadConnectors patched process.emitWarning globally at every startup — even
for instances that never use SQLite. Now that node:sqlite is loaded lazily
inside connect(), the hook can be too: convert the suppress module to an
idempotent function and call it right before the dynamic import. Non-SQLite
processes no longer touch process.emitWarning.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3d68763 commit 1b9c058
12 files changed
Lines changed: 157 additions & 242 deletions
File tree
- .github/workflows
- docs
- src
- connectors
- __tests__
- sqlite
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
| |||
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
54 | | - | |
| 58 | + | |
| 59 | + | |
55 | 60 | | |
56 | 61 | | |
57 | | - | |
| 62 | + | |
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
| |||
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
65 | | - | |
66 | 64 | | |
67 | 65 | | |
68 | 66 | | |
| |||
0 commit comments