Skip to content

test: lock Postgres NDJSON meta from result.fields (#11) - #13

Merged
ChuTingzj merged 1 commit into
mainfrom
cursor/postgres-meta-regression-27e4
Sep 21, 2026
Merged

ChuTingzj merged 1 commit into
mainfrom
cursor/postgres-meta-regression-27e4

Conversation

@ChuTingzj

@ChuTingzj ChuTingzj commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Relates to #11 — #11

Rebased onto main after #12 squash-merge (c09de54). Tests only; no runner image or npm publish.

Why

#12 landed the runner fix (streamPgQuery + unit tests on event objects). This PR locks the host-visible NDJSON contract that issue #11 actually broke: consumeNdjsonResult getting columns: [] because pg 8.x never emits fields.

Asserted

Against the Postgres execute path (streamPgQuery) with a mocked pg 8.x Result (FieldDef[] on result.fields):

  1. Query never emits fields — Pg8Query.emit('fields') throws; fieldsEmitted === 0.
  2. NDJSON meta — first line is {"type":"meta","columns":["order_date","daily_total"]} from result.fields.
  3. Host consumer — consumeNdjsonResult returns those column names (not []).
  4. Zero-row schema — end with result.fields still writes meta then end.
  5. execute.js wiring — streamPg delegates to streamPgQuery and does not query.on('fields').

These tests fail on fields-event-only code (rows/end, no meta, columns: []) and pass on current main + this commit.

How to run

pnpm test
pnpm typecheck
pnpm build

Local: 63 tests, 0 failures. Do not merge. Do not publish npm.

Open in Web Open in Cursor 

@ChuTingzj
ChuTingzj marked this pull request as ready for review September 21, 2026 04:52

@ChuTingzj ChuTingzj left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Pre-scan (533f9d4)

Blocker for merge: base is still cursor/postgres-meta-columns-6f52 (4f5752a), not main (c09de54 where #12 landed). Rebase onto main first, then re-request review.

Content (looks good once rebased): locks the real #11 failure mode — host consumeNdjsonResult gets non-empty columns from NDJSON meta, with a Query that throws if fields is emitted. Zero-row schema + execute.js / pg-query-stream.js source guards are the right layer above #12’s unit tests.

No code must-fix in the test file itself. Hold merge until rebase.

Regression stacked on the #12 runner fix: pg 8.x Result.fields must
become NDJSON meta columns even when Query never emits a fields event.

Co-authored-by: zhangjing <zhangjing798@qq.com>
@cursor
cursor Bot force-pushed the cursor/postgres-meta-regression-27e4 branch from 533f9d4 to 6875bdf Compare September 21, 2026 04:55
@cursor
cursor Bot changed the base branch from cursor/postgres-meta-columns-6f52 to main September 21, 2026 04:55

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved: Cursor Bugbot completed successfully with no findings that need human review. No approval-policy files apply, and this automation has not assigned reviewers.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@ChuTingzj ChuTingzj left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Re-scan (6875bdf)

Rebase blocker cleared — base is main (c09de54). Locks #11 host contract: NDJSON meta from result.fields, no fields event, consumeNdjsonResult.columns non-empty, zero-row schema, execute.js wiring. No must-fix.

OK to merge (human). Digest/0.1.4 stays on the other line.

@ChuTingzj
ChuTingzj merged commit e949d42 into main Sep 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants