node-postgres
node-postgres copied to clipboard
Pool "query shortcut" does not work with cursors
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!
ah yeah you're right that should be fixed!