fix(db): return undefined for empty bun:sqlite .get() results - #14203
Merged
diegosouzapw merged 2 commits intoSep 22, 2026
Merged
diegosouzapw merged 2 commits into
diegosouzapw merged 2 commits into
Conversation
bun:sqlite's Statement.get() returns null when no row matches, while better-sqlite3, node:sqlite and sql.js return undefined. The call sites are typed and written against undefined (`get(...) as Row | undefined`, and isExclusiveConnectionActivelyLeased compares with `!== undefined`), so when the server runs under Bun every connection looked exclusively leased: dashboard connection tests reported LEASE_ACTIVE, usage refresh was deferred with 409, and the model-sync scheduler found no connections to sync. Normalize the no-row result in the Bun adapter so all drivers share one contract. Covered by a driver-independent unit test that runs in the Node shards and a Bun-only test against the real bun:sqlite driver.
Owner
|
Thanks @Ercaner1988 — merging via the release merge-train. Validated in local merge-train (mt-train10c) on the devbox @ train tip 4d841aa1c740bbaa03868dc0a403c62099a99a42 with the 72 sibling PRs of this batch: typecheck:core, file-size, complexity, cognitive-complexity, changelog-integrity green; changed-area node:test 831/831 (0 failing) and vitest 480/482 — the two reds are |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bun:sqlite'sStatement.get()returnsnullwhen no row matches.better-sqlite3,node:sqliteandsql.jsreturnundefined, and the rest of the code is written against that (get(...) as Row | undefined;isExclusiveConnectionActivelyLeasedcompares with!== undefined).release/v3.8.51): the dashboard connection test returnedLEASE_ACTIVE(skipped, 0 ms) for every connection tried (antigravity and mistral), usage refresh was deferred with 409, and the model-sync scheduler loggedNo connections with autoSync enabled, whileexclusive_connection_leaseswas empty and no API key had thelease:exclusivescope.nulltoundefined, so all drivers share one contract. The change is confined to the best-effort Bun adapter; the Node drivers are untouched, and it does not change the runtime support policy (Node remains the supported runtime).nullfor a.get()with no matching row.Related Issues
Validation
Choose the change type and focused loop from the
Contribution Golden Path. The full unit suite,
Vitest, the 60% coverage gate, and the production build all run in CI on this PR (#8329):
check-db-rulespasses; thetest:bun:dbfile set (bunSqliteAdapter,driverFactory,cliSqlite) passes 24/24 on Bun 1.4.2. The two new tests failed before the change (actual: null, expected: undefined) and pass after it.npm run lint: ESLint (repo config and suppressions) and Prettier were run on the two changed files and are clean. The full-repo lint is left to CI.release/v3.8.51tip (7a921299c, 2026-09-19).Tests Added Or Updated
tests/unit/db-adapters/bunSqliteAdapter.test.ts: two new tests. One uses a fake driver whoseget()returnsnull, so it runs under any runtime, including the Node shards. The other runs against the realbun:sqliteand is skipped outside Bun (it is picked up bytest:bun:db).Coverage Notes
src/lib/db/adapters/bunSqliteAdapter.tschanges by one expression. The fake-driver test covers it on every runtime; the real-driver test covers it under Bun.typecheck:core, the full-repo lint and the production build. CI runs them on this PR.Reviewer Notes
!== undefinedchecks and the| undefinedtypings elsewhere assume the shared contract, so normalizing once here covers every caller instead of patching call sites one by one.