node-postgres icon indicating copy to clipboard operation
node-postgres copied to clipboard

Pool "query shortcut" does not work with cursors

Open mschilde opened this issue 3 years ago • 1 comments

Connection pools provide a query shortcut, which is convenient. It currently does not work with cursors though.

Example (Typescript) code:

  const pool = new Pool({
    user: 'user',
    host: 'host',
    database: 'postgres',
    port: 5432,
    password: 'password',
    max: 4
  });

  const query = 'SELECT * FROM generate_series(0, 200)';
  const rowCursor = pool.query(new Cursor(query));

[...]

rowCursor is not a cursor. If I await pool.query the promise will never resolve. The cursor works fine if I fetch a connection from the pool manually and release it later.

Can you either please fix this or add it to the documentation? Or did I misunderstand something?

Btw, thanks for all the work on this library!

mschilde avatar Aug 11 '22 08:08 mschilde

ah yeah you're right that should be fixed!

brianc avatar Aug 15 '22 14:08 brianc