Skip to content

test(trilean-sql): check the same compiled fragments against PGlite, which needs no Docker - #19

Merged
Mearman merged 1 commit into
mainfrom
test/pglite-integration
Sep 3, 2026
Merged

test(trilean-sql): check the same compiled fragments against PGlite, which needs no Docker#19
Mearman merged 1 commit into
mainfrom
test/pglite-integration

Conversation

@Mearman

@Mearman Mearman commented Sep 3, 2026

Copy link
Copy Markdown
Member

trilean-sql's integration suite is the only thing that turns the three-valued-logic claim from a design statement into a measured one — asserting that ("age" > $1) is indeterminate-preserving is a claim about PostgreSQL's planner, not about the string. Until now that suite needed a working Docker daemon, so on any machine without one the claim went back to being asserted rather than measured, and the package's own README had to say so.

This adds test/integration/pglite.test.ts, the same parity suite against PGlite. PGlite is not a Postgres-compatible reimplementation or a dialect of its own — it is PostgreSQL's own source compiled to WebAssembly and run in process. select version() from it reports:

PostgreSQL 18.3 (PGlite 0.5.8) on wasm32-unknown-emscripten, compiled by emcc 3.1.74, 32-bit

Same parser, same planner, same NULL semantics. So every construct the compiler emits under dialect: "postgres"$N::type casts, ~/!~, double-quoted identifiers, NULL::boolean — is handled by the same code that handles it on a server, and dialect: "postgres" needs no new value for it. That is what makes this a parity suite rather than a smoke test: it is worth executing every case, because executing every case is what establishes PGlite as a verified target of the dialect instead of an assumed one.

The two files are a near-verbatim structural copy of each other on purpose. A shared harness parameterised over both engines would make them agree by construction, and agreement by construction is the one thing this cannot establish — the point is that two independently-driven executions of the same compiled SQL land on the same rows. The divergence between the files is confined to how a connection is opened and a statement is run; the column fixture (src/test-support/columns.ts) is genuinely shared, as it already was with the unit suite.

Both files live in the same vitest integration project rather than getting one project each, because they are the same tests: vitest run --project integration is the whole integration surface, and a third engine would be a new file rather than new configuration. pnpm test:integration now runs 38 cases, 19 per engine, and CI's existing Integration job picks the new file up with no workflow change.

Nothing under src/ is touched, and postgres.test.ts is byte-for-byte unchanged — the container-backed suite stays exactly as it was, still the reference the WASM build is being checked against. Incidentally the two now disagree on nothing across two Postgres majors: the container runs postgres:17-alpine, PGlite is built from 18.3.

…which needs no Docker

PGlite is PostgreSQL compiled to WebAssembly and run in process, so every
construct the postgres dialect emits reaches the same parser and planner,
but nothing measured that: the dialect's only executing suite was the
container-backed one.

pglite.test.ts is that suite's parity harness case for case -- the same
seeded subjects fixture and subjectOptions, the same dual execution of
each tree through the compiled SQL and through evaluatePredicate per row,
the same adversarial set (NULL propagation and absorption, the empty
memberOf encoding under negation, NaN, injection via a value and via a
hostile columnFor identifier, the deep mixed tree) -- driven through
PGlite's own in-process query() instead of testcontainers and pg.

Kept a near-verbatim copy rather than a harness parameterised over both
engines: agreement by construction is the one thing a parity suite cannot
establish. It also makes the three-valued claim measurable on a machine
with no Docker daemon, which until now no suite was.
@Mearman
Mearman marked this pull request as ready for review September 3, 2026 15:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ⚠️ Failed 2026-09-03T15:09:16.125365Z 8b88928 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Mearman
Mearman merged commit d11ca6e into main Sep 3, 2026
13 checks passed
@Mearman
Mearman deleted the test/pglite-integration branch September 3, 2026 15:48
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant