No description
  • Emacs Lisp 59%
  • Python 39%
  • Makefile 1.8%
  • Shell 0.2%
Find a file
Kinneyzhang bd860bc628
Some checks are pending
Repository structure / structure (push) Waiting to run
feat(sqlite): upsert rows and expose the primary key as identity
Consumers that keep a local copy of remote records had to load every
stored row, diff it in Lisp and choose insert or update per record,
because replace only ran an UPDATE and a missing identity looked like a
successful zero-change write while the memory source signals.

Add an upsert operation that inserts or updates by primary key in one
transaction, make replace and update signal for a missing identity, and
expose the table primary key as the Data Controller :item-key capability
so selection identity needs no extra callback.  The weread application
builds its SQLite highlight index with one upsert per row.

Validation: make check (11 acceptance scenarios, 0 unexpected; API
inventory 9 declarations verified).
2026-10-01 20:53:41 +08:00
.githooks chore(git): enforce logical commits and structured messages 2026-09-13 11:15:14 +08:00
.github/workflows refactor(api)!: expose the root entry and enforce public contracts 2026-09-13 12:56:03 +08:00
docs feat(sqlite): upsert rows and expose the primary key as identity 2026-10-01 20:53:41 +08:00
lisp feat(sqlite): upsert rows and expose the primary key as identity 2026-10-01 20:53:41 +08:00
scripts fix(scripts): check secondary jj workspaces 2026-09-25 15:55:56 +08:00
tests feat(sqlite): upsert rows and expose the primary key as identity 2026-10-01 20:53:41 +08:00
.editorconfig chore: establish consistent repository and acceptance policy 2026-09-13 11:10:50 +08:00
.gitignore chore: establish consistent repository and acceptance policy 2026-09-13 11:10:50 +08:00
CHANGELOG.md refactor(db)!: expose database backends through etaf-db 2026-09-15 11:27:14 +08:00
etaf-db.el feat(sqlite): upsert rows and expose the primary key as identity 2026-10-01 20:53:41 +08:00
Makefile build(integration): remove retired TP load paths 2026-09-18 17:06:48 +08:00
README.md refactor(db)!: expose database backends through etaf-db 2026-09-15 11:27:14 +08:00
README.zh-CN.md refactor(db)!: expose database backends through etaf-db 2026-09-15 11:27:14 +08:00

ETAF DB

中文

etaf-db provides database backends for the ETAF framework. SQLite is the only currently implemented backend. It adapts Emacs' built-in SQLite support to etaf-data-source; ETAF core continues to own Data Controllers and reactive state.

Installation and use

Requires Emacs 29.1 or later with SQLite support and ETAF 0.2.1 or later. For a checkout, add the repository root and ETAF's dependency roots to load-path, then use (require 'etaf-db). Package archives include the root entry and lisp/. etaf-db.el documents the supported API. SQLite-specific constructors retain the etaf-sqlite-* prefix because their schema and storage arguments describe that backend.

(require 'etaf-db)

(let* ((table (etaf-sqlite-table
               'items
               (list (etaf-sqlite-column :id "id" :type 'integer :primary t)
                     (etaf-sqlite-column :name "name" :type 'text))
               :id))
       (database (etaf-sqlite-database "~/items.sqlite" table)))
  (etaf-sqlite-initialize database)
  (let ((controller (etaf-data-controller
                     (etaf-sqlite-source database) :auto-load t)))
    (unwind-protect
        (message "%S" (etaf-value (etaf-data-items controller)))
      (etaf-data-stop controller))))

The SQLite backend owns schema validation, short-lived connections, pagination, queries and synchronous mutations. Its source uses the existing ETAF Data Source contract. There is no separate database controller, ORM or backend dispatch protocol. Non-database integrations can implement the same source contract independently.

See the manual for supported queries, writes and lifecycle, including the optional :mutate-v2 t source capability.

Development

Run make setup-hooks after cloning. make structure-check is the fast structure and API boundary gate. make check EMACS=/path/to/emacs adds compilation, entry validation and the public scenarios in tests/acceptance.json. make test runs those same correctness scenarios. GUI and performance acceptance use the consuming examples' separate workflows.