IF Commons GitHub

sql-drivers

0056Active

0056-sql-drivers · owner if · domain data

Requirements

FR-001checkpassing

An adapter MUST make a Driver from node:sqlite or bun:sqlite, a pg client or pool, PGlite, DuckDB's node-api connection and Bun's SQL, each typed by the shape of the client and not by its package, so that the library depends on none.

Enforced (check): .github: cd commons/data && bun run verify — suite/drivers.test.ts: each adapter runs the same script and gives the same rows on the real client: node:sqlite, DuckDB, PGlite and pg over a socket, and bun:sqlite and Bun's SQL on Bun; and driverFor picks the adapter from the shape of the client

Proved by: data/suite/drivers.test.ts

Written in: data/sql/drivers/mod.ts

Tests: passed: suite/drivers.test.ts each adapter runs the same script and gives the same rows on the real client: node:sqlite,

FR-002checkpassing

The same script MUST give the same rows through every adapter on the real client, a wide integer MUST be a number, a row a plain object, and a refusal or a failing query a rejection; driverFor MUST pick the adapter from the shape of the client.

Enforced (check): .github: cd commons/data && bun run verify — suite/drivers.test.ts: each adapter runs the same script and gives the same rows on the real client: node:sqlite, DuckDB, PGlite and pg over a socket, and bun:sqlite and Bun's SQL on Bun; and driverFor picks the adapter from the shape of the client

Proved by: data/suite/drivers.test.ts

Written in: data/sql/drivers/mod.ts

Tests: passed: suite/drivers.test.ts each adapter runs the same script and gives the same rows on the real client: node:sqlite,

FR-003checkpassing

A client of no known shape MUST be refused with a message that says what is looked for.

Enforced (check): .github: cd commons/data && bun run verify — suite/drivers.test.ts: a client of no known shape is refused with a message that says what is looked for, and a row is made plain: a wide integer a number, an object with no prototype an ordinary one

Proved by: data/suite/drivers.test.ts

Written in: data/sql/drivers/mod.ts

Tests: passed: suite/drivers.test.ts a client of no known shape is refused with a message that says what is looked for, and a r

Out of scope

  • Connection pools, transactions across calls and parameters: the driver takes text.

Edge cases

  • Rows that a client gives with a null prototype are made plain, per FR-002.

Assumptions

  • The engines of the tests are SQLite, DuckDB and PGlite (PostgreSQL).

Open questions

  • None.

Key entities

  • Adapter - a function from a client of a known shape to a Driver.

Success criteria

SC-001success criterion

Each requirement is proved by a test on real engines and bun run verify is green.

Review & acceptance checklist

  • [x] Every requirement is testable (MUST / MUST NOT), not aspirational
  • [x] No company fact is asserted here
  • [x] Every open item is marked, not silently decided

Cited by

Data, sql/drivers/mod

Titles, headings, exports, tables, columns and requirements. Esc closes.