Skip to content

Make streaming cursors subtype DBInterface.Cursor - #36

Merged
quinnj-bot[bot] merged 1 commit into
mainfrom
claude/cursor-supertype
Oct 30, 2026
Merged

quinnj-bot[bot] merged 1 commit into
mainfrom
claude/cursor-supertype

Conversation

@quinnj-bot

@quinnj-bot quinnj-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

What

Postgres.Cursor (what Postgres.cursor returns) now subtypes DBInterface.Cursor.

Why

Code that dispatches on the abstract cursor type skipped streaming Postgres cursors. The motivating case is JuliaServices/StructUtils.jl#95, which reads and writes any DBInterface.Cursor as an array of its rows. With both changes, query results stream straight into JSON:

Postgres.transaction(conn) do tx
    JSON.json(io, Postgres.cursor(tx, "SELECT id, name FROM users"; fetchsize=1000); jsonlines=true)
end

Today JSON.json on a cursor writes the cursor's fields, starting with its whole Connection. Postgres.Result (from DBInterface.execute) is an AbstractVector of rows and already writes as an array of row objects, so it is unaffected. DBInterface defines no methods on DBInterface.Cursor that change this package's behavior.

Verification

  • New assertion in the "Cursor Streaming" testset: cur isa DBInterface.Cursor.
  • Full suite with the Docker integration tests (POSTGRES_REQUIRE_INTEGRATION=true, postgres:16) on Julia 1.12.6: 9242/9242.
  • End to end with StructUtils#95 and JSON 1.13 against PostgreSQL 16.

🤖 Generated with Claude Code

Postgres.cursor returns a Postgres.Cursor, which did not subtype
DBInterface.Cursor, so code that dispatches on the abstract cursor type
(such as StructUtils' DBInterface extension, which writes a cursor as an
array of rows) did not apply to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@quinnj-bot
quinnj-bot Bot marked this pull request as ready for review October 30, 2026 14:20
@quinnj-bot
quinnj-bot Bot merged commit 9b0d6bb into main Oct 30, 2026
16 checks passed
@quinnj-bot quinnj-bot Bot mentioned this pull request Oct 30, 2026
quinnj referenced this pull request Oct 30, 2026
Co-authored-by: Jacob Quinn <quinn.jacobd@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant