electric-sql / electric-sql/pglite

Support for cursors / `pg-cursor`

Open
#833 7 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
16k
Forks
442
Avg merge
20h 19m
Merged PRs (30d)
7

Description

When using `pg-cursor` with PGlite:

```typescript
import { PGlite } from '@electric-sql/pglite';
import Cursor from 'pg-cursor';

const db = new PGlite();
const cursor = db.query(new Cursor('SELECT * FROM large_table'));
await cursor.read(100);
```

It fails because PGlite doesn't support the extended query protocol features needed for cursors, I think (`TypeError: chunkReader.read is not a function`, `The "src" argument must be of type string. Received an instance of Cursor`)

**Use case**

I'm trying to use PGlite for testing, while production uses PostgreSQL with cursor-based streaming (via `pg-cursor`).

Currently, I have to use a real PostgreSQL instance for tests that involve streaming, which defeats the purpose of using PGlite.

**To Reproduce**
- PGlite version: `0.3.11`
- node version: `v24.8.1`

**Expected behavior**

Cursors should work similar to how they work with `node-postgres` + PostgreSQL, allowing:
- Server-side cursors via `DECLARE CURSOR`
- Portal-based result fetching with row limits
- Batch processing of large datasets

**Additional context**

Maybe related to #223 (prepared statements) - both require extended query protocol support (`Parse`, `Bind`, `Execute` with row limits).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.