porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.26k stars 262 forks source link

ReservedSql appears to have methods it does not have #713

Open rytido opened 10 months ago

rytido commented 10 months ago
const sqli = await sql.reserve();
await sqli.begin(async (sql) => await sql`select 1`);
sqli.release();
// sqli.begin is not a function

Is there a technical reason transactions are not supported by reserved connections?

porsager commented 10 months ago

I suppose this is typescript related?

If you reserve a connection you are expected to handle transactions yourself by calling sqlbegin ... etc, so it is correct that there is no sql.begin function on a reserved instance.

Feel free to make a PR for the typescript if that's what your issue is about.

rytido commented 10 months ago

Gotcha, yeah, just the typescript. I'll try to get around to a PR. Love this library, thank you.

Ericnr commented 2 weeks ago

I suppose this is typescript related?

If you reserve a connection you are expected to handle transactions yourself by calling sqlbegin ... etc, so it is correct that there is no sql.begin function on a reserved instance.

Feel free to make a PR for the typescript if that's what your issue is about.

is there a good reason why a reserved connection couldn't have the .begin method, along with all other methods sql has?