postgres: Throwing exceptions from sql.begin has some caching issue
This code should fail with exception ‘throws from tx’, but instead fails with ‘SELECTexception’ syntax error:
async function main() {
try {
await sql.begin(async sql => {
try {
let r = await sql`SELECTexception`;
} catch (ex) {
throw new Error('throws from tx');
}
});
} finally {
await sql.end();
}
}
Looks like the original exception is cached somewhere in sql.begin()…
Other than that, v3 is beautiful. 😃 I’ve made a bit of a quick and dirty compat layer for migrating from vitaly-t/pg-promise
:
https://megous.com/dl/tmp/compat.patch
And was able to use your DB connector on a fairly large project that uses pg-promise just like that, and it works nicely. 😃 I’ve only found this issue so far during porting.
Great job with v3 😃 I’m looking forward to using those lovely batched cursors, and streaming replication protocol support. 😃
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (8 by maintainers)
Even better. Tested, and works fine.