Skip to content

feat: add SQLite connector - #56

Merged
cccadet merged 1 commit into
mainfrom
feat/sqlite-connector
Nov 30, 2026
Merged

cccadet merged 1 commit into
mainfrom
feat/sqlite-connector

Conversation

@cccadet

@cccadet cccadet commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a SQLite connector built on Node 22's built-in node:sqlite, so no new native dependency is needed.

  • New package @omni-sql/adapters-sqlite
    • Endpoint is an absolute file path or :memory:. A missing file fails instead of being created silently.
    • Schemas are main plus ATTACHed databases.
    • Introspects tables, views, PK, FK (including REFERENCES t with no column), UNIQUE, defaults, indexes and built-in functions.
    • Queries are bounded and streamed, with an abort check between batches.
    • Big integers arrive as strings and BLOBs as 0x… hex.
    • EXPLAIN QUERY PLAN is shown as a tree, and validation is prepare-only.
    • Supports view and table definitions, and parameterized updateRow/insertRow.
    • Read-only runs (used by MCP) go through a second connection opened read-only. For :memory: they use query_only and reject PRAGMA, ATTACH and DETACH.
  • Wiring
    • Dialect added to ts-types and dialect-descriptors.
    • Backend: handler registration, MCP dialect list, diagnostics and connection.test.
    • Coverage lists updated in scripts/test-coverage.mjs and Sonar.
  • Errors: SQLite errors used to reach the UI as "Internal error". They now show a sanitized SQLite: … message (safeSqliteDatabaseError).
  • Desktop
    • Connection dialog: new SQLite type with a file picker and an "Open read-only" option.
    • Table editor DDL: unsupported ALTERs produce a "rebuild table" comment instead.
    • Also adds the formatter mode, icon, labels, upsert and integrity commands, import support, and i18n (en, pt-BR, zh-CN).
  • Docs: README, DATABASE-SUPPORT (new SQLite section), CONNECTIONS, ARCHITECTURE, MCP and CLAUDE.md.

Also adds a missing /* global */ header to scripts/test-coverage.mjs. Without it the precommit lint fails as soon as the file is staged.

Known limitations

  • node:sqlite is synchronous. A long query blocks the backend until it finishes and cannot be cancelled.
  • SQLite ALTER TABLE cannot change a column's type, NULL or default, or the PK. The table editor emits guidance comments instead.

Test plan

  • adapters-sqlite: 8 tests against real files, all passing. They cover endpoint validation, ATTACH introspection, limits, bigint and BLOB values, read-only mode, explain and validate, indexes and definitions, edits with odd identifiers, and streaming with abort.
  • Backend: 101 pass, 10 skipped (optional integration tests that were already skipped). One new rpc-errors test.
  • Desktop: 159 tests pass. 2 new SQLite DDL tests.
  • Typecheck and lint pass. The pre-push hook (test:fast) passes.
  • Manual check in the browser preview against an isolated backend:
    • A mistyped path is rejected and no file is created.
    • Test, save and restore work across a backend restart.
    • Metadata sync, a JOIN query, the invalid-SQL error message and EXPLAIN all work.
  • Grid row editing in the UI was not checked because it needs the JVM sidecar. It is covered by the adapter tests.

🤖 Generated with Claude Code

Add @omni-sql/adapters-sqlite on built-in node:sqlite: file/:memory:
endpoints (no file creation on typos), ATTACH-aware schemas, tables,
views, keys, indexes, functions, bounded/streamed queries, read-only
second connection, EXPLAIN QUERY PLAN, validation and row editing.

Wire the dialect through ts-types, descriptors, backend handlers, MCP,
diagnostics and the desktop UI (connection dialog with file picker and
read-only option, table DDL, formatter, icon, commands, i18n). Surface
sanitized SQLite errors instead of "Internal error". Update docs and
coverage lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cccadet
cccadet merged commit 7ca4a0f into main Nov 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant