Skip to content

test: replace better-sqlite3 with node:sqlite - #3510

Merged
ascorbic merged 1 commit into
mainfrom
codex/node-sqlite-tests
Sep 27, 2026
Merged

ascorbic merged 1 commit into
mainfrom
codex/node-sqlite-tests

Conversation

@ascorbic

Copy link
Copy Markdown
Member

What does this PR do?

Replaces better-sqlite3 in the core and workerd test suites with the existing node:sqlite compatibility adapter.

The adapter now supports the direct test usage that previously depended on better-sqlite3: construction, exec, get, variadic statement bindings, connection state, and idempotent close. The native dependency, its type package, build permission, bundler external, lockfile entries, and Docker compiler toolchain are removed.

This keeps tests on the same built-in SQLite driver used by the Node runtime and removes the native compilation/download requirement from installs and container builds.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added and reviewed the user-facing changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...
  • I have included screenshots below if this PR changes the UI

The i18n, changeset, Discussion, and screenshot items are not applicable: this only changes test infrastructure and development dependencies, with no admin UI or published user-facing behavior.

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Codex (gpt-5.6-sol)

Screenshots / test output

Not applicable (no UI changes).

Validated with:

  • pnpm format
  • pnpm build
  • pnpm typecheck
  • pnpm lint:quick
  • pnpm --silent lint:json | jq '.diagnostics | length' (0 diagnostics)
  • 650 affected core unit tests
  • 316 affected core integration tests
  • 126 affected workerd tests
  • SQLite CLI migration tests (3/3)
  • Site matrix smoke tests (11/11)

@changeset-bot

changeset-bot Bot commented Sep 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8f61911

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Scope check

This PR changes 664 lines across 93 files. Large PRs are harder to review and more likely to be closed without review.

If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs.

See CONTRIBUTING.md for contribution guidelines.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://codex-node-sqlite-tests.try.emdashcms.com, https://codex-node-sqlite-tests-emdash-playground.emdash-cms.workers.dev (commit 8f61911)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://9896e3b8.try.emdashcms.com, https://9896e3b8-emdash-playground.emdash-cms.workers.dev 8f61911 2026-09-27T11:08:12.909Z Visit the dashboard ↗

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the right change for the stated goal. EmDash's runtime already moved to node:sqlite; finishing the same migration in the test suites removes a native compilation dependency from developer installs and container builds, and keeps test behavior aligned with production.

I checked:

  • Unified diff and full authored files for packages/core/src/db/node-sqlite-compat.ts, affected tests, packages/core/package.json, packages/workerd/package.json, pnpm-workspace.yaml, pnpm-lock.yaml, and Dockerfile.
  • Searched the tree for remaining better-sqlite3 imports/usages (only historical CHANGELOG entries and bot eval fixtures remain).
  • Verified the node-sqlite-compat adapter supports both the array-binding contract Kysely uses and the direct variadic/exec/get/close usage that tests previously routed through better-sqlite3.
  • Confirmed transaction replacements in content-order-plan.test.ts and direct-executor.test.ts are equivalent BEGIN/COMMIT/ROLLBACK wrappers.
  • Confirmed the node:sqlite import is available on the declared node >=22.16 engine.

The adapter change is shared with the production emdash/db/sqlite runtime path, but the behavior is additive and backward-compatible: the same prepare/exec/close surface Kysely needs remains, close becomes idempotent, and parameter normalization still flattens the single-array case. No AGENTS.md conventions are violated (no UI/i18n changes, no new logged-out queries, no security-sensitive SQL interpolation, no questionable comments), and a changeset is not required for this test-only/dependency-cleanup PR.

@pkg-pr-new

pkg-pr-new Bot commented Sep 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@3510

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@3510

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@3510

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@3510

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@3510

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@3510

emdash

npm i https://pkg.pr.new/emdash@3510

create-emdash

npm i https://pkg.pr.new/create-emdash@3510

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@3510

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@3510

@emdash-cms/plugin-test

npm i https://pkg.pr.new/@emdash-cms/plugin-test@3510

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@3510

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@3510

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@3510

@emdash-cms/registry-loader

npm i https://pkg.pr.new/@emdash-cms/registry-loader@3510

@emdash-cms/registry-moderation

npm i https://pkg.pr.new/@emdash-cms/registry-moderation@3510

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@3510

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@3510

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@3510

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@3510

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@3510

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@3510

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@3510

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@3510

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@3510

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@3510

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@3510

commit: 8f61911

@github-actions github-actions Bot added review/approved Approved; no new commits since overlap labels Sep 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@ascorbic
ascorbic merged commit 65181cd into main Sep 27, 2026
45 checks passed
@ascorbic
ascorbic deleted the codex/node-sqlite-tests branch September 27, 2026 13:16
danielmlr added a commit to danielmlr/emdash that referenced this pull request Sep 27, 2026
emdash-cms#3409 pinned the pivot join for temp sorts and freed it for every indexed
sort. This branch frees it only for a single large term under an indexed
sort with a LIMIT, which already keeps temp sorts pinned, so its join
condition stays. The comment keeps emdash-cms#3409's reason for the temp-sort pin
and drops the claim that D1 keeps no planner statistics, which emdash-cms#3409's
production statistics contradict. emdash-cms#3409's join test moves into the
large-term block, the only shape whose indexed sort still frees the join.

emdash-cms#3510 replaced better-sqlite3, so the plan test uses the node:sqlite
helper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core review/approved Approved; no new commits since size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant