Skip to content

fix: normalize scheduled_at comparison in snapshot export#1159

Draft
jp-knj wants to merge 2 commits into
emdash-cms:mainfrom
jp-knj:fix/sqlite-snapshot-scheduled-export
Draft

fix: normalize scheduled_at comparison in snapshot export#1159
jp-knj wants to merge 2 commits into
emdash-cms:mainfrom
jp-knj:fix/sqlite-snapshot-scheduled-export

Conversation

@jp-knj
Copy link
Copy Markdown

@jp-knj jp-knj commented May 24, 2026

What does this PR do?

Same bug as #917, but in snapshot.ts:297. The WHERE clause compares scheduled_at with datetime('now') as raw text. On SQLite the formats differ, so scheduled rows were missing from snapshots until UTC midnight.

This PR mirrors #1157: use strftime('%Y-%m-%dT%H:%M:%fZ', 'now').

It is a draft for now. I will set it ready after #1157 is merged.

Follow-up to #917.

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 a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 4.7

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 24, 2026

🦋 Changeset detected

Latest commit: f646db7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

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

@jp-knj jp-knj changed the title fix(core): normalize scheduled_at comparison in snapshot export fix: normalize scheduled_at comparison in snapshot export May 24, 2026
@jp-knj jp-knj force-pushed the fix/sqlite-snapshot-scheduled-export branch from c77b05d to cc64a0e Compare May 24, 2026 08:48
@jp-knj jp-knj marked this pull request as ready for review May 24, 2026 10:29
Copilot AI review requested due to automatic review settings May 24, 2026 10:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a SQLite/D1 snapshot export bug where scheduled rows could be omitted due to comparing scheduled_at (ISO string) against datetime('now') (space-separated), causing incorrect lexicographic ordering until UTC midnight.

Changes:

  • Normalize the SQLite “now” value in the snapshot export query to ISO 8601 via strftime('%Y-%m-%dT%H:%M:%fZ', 'now').
  • Add integration tests to ensure scheduled rows are included/excluded based on whether scheduled_at is past/future.
  • Add a patch changeset documenting the fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/core/src/api/handlers/snapshot.ts Updates the SQLite snapshot export WHERE clause to compare against an ISO-formatted “now”.
packages/core/tests/integration/snapshot/snapshot.test.ts Adds coverage for scheduled content inclusion/exclusion in snapshot generation.
.changeset/cold-boats-joke.md Patch changeset describing the snapshot export fix for SQLite/D1.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/api/handlers/snapshot.ts
Comment thread packages/core/tests/integration/snapshot/snapshot.test.ts
@jp-knj jp-knj force-pushed the fix/sqlite-snapshot-scheduled-export branch from cc64a0e to 6bd3446 Compare May 24, 2026 11:04
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 26, 2026

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

emdash

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

create-emdash

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

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

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: f646db7

@jp-knj jp-knj marked this pull request as draft May 26, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants