-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create beginPrepared function #628
create beginPrepared function #628
Conversation
My idea was that .prepare() would be available on the sql transaction instance, so you would still use .begin() Like this: await sql.begin(async sql => {
...queries
await sql.prepare(name)
}) |
This would have been a great option if running other queries after the |
There's nothing preventing us from implementing it such that you can? sql.prepare(name) can simply be a function that caches the name and signals that instead of commit we should do prepare transaction name |
So your idea is that |
The cool thing is that you'll also be able to conditionally decide if you want to prepare or commit the transaction depending on the result of queries in the transaction. |
Exactly. |
Yes that would be nice, I'll implement it like so. |
Cool.. Mind adding tests and documentation for this new method? |
done |
Looks good so far. Perhaps the test should open another connection and try to commit the prepared transaction? |
Yeah I just thought of that. See if the current test would suffice. |
🎉 perfect.. Seems we need to enable prepared transactions in the bootstrap script for tests to work. Also - very curious what scenario you're in - needing this feature 😋 sounds exotic 🏝️ |
Add this line to bootstrap.js |
We're trying to implement distributed transactions using the 2PC method. =) |
I don't think this has enabled them. |
No, seems it can only be set at start, so we need to edit postgresql.conf and restart 😐 |
I think that could be handled if a line is added to the |
I'd like an idempotent solution in the bootstrap.js script since I run tests most locally (and that ought to fix github as well). I'm looking into a solution ;) |
I remember why i hated this now 😮💨 Doing a cross platform way of restarting the server is quite annoying 😅 I think for now saying you have to do this locally yourself is ok, and the following line to replace your's in the .yml ought to do the trick for github actions.:
|
Yeah I can't think of a pretty way of doing that either. 😂 |
Everything looks good now 👏 |
* create beginPrepared function * change implementation to new method * add prepare method type to TransactionSql * add documentations and test * fix test * enable prepared transactions in the bootstrap script * enable prepared transactions in the github actions setup file * fix github actions * fix github actions yml file
* Initial support for cloudflare * Types here are not needed * Include cloudflare in npm * Allow crypto to be async to support WebCrypto polyfills * Polyfill crypto with WebCrypto for cloudflare * Use crypto polyfill for cloudflare * Not ready for tests on CF yet * build * build cf * build * README.md - improve the "Multiple statements in one query" section - add links for the official documentation - escape the backtick character - change the subtitle to "await sql``.simple()" instead of "await sql`select 1; select 2;`.simple()" (to be coherent with the other subtitles) - add a small example below * Ensure number options are coerced from string - fixes #622 * Add sql.reserve method * build * create beginPrepared function (#628) * create beginPrepared function * change implementation to new method * add prepare method type to TransactionSql * add documentations and test * fix test * enable prepared transactions in the bootstrap script * enable prepared transactions in the github actions setup file * fix github actions * fix github actions yml file * Please the linter * build * Fix for using compatibility_flags = [ "nodejs_compat" ] instead * build * please eslint * draft: Cloudflare works ! 🎉 (#618) * Reworked from source cloudflare branch feat: reran transpile fix linter feat: final touches + test files squashed 2 commits fix: Polyfills bulk (to please linter) fix: Removed MD5 + put back SHA in the digest() squashed 5 commits fix: cloudflare workers deployment feat: fixed auth fix: encrypt not found in worker :( fix: postgres SASL fix: linting * fix: merge cleanup --------- Co-authored-by: wackfx <[email protected]> * Switch to performance.now * Please the linter * Don't collect polyfills (keep line numbers similar to src) * Simplify manual test script * build --------- Co-authored-by: Paulo Vieira <[email protected]> Co-authored-by: Shayan Shojaei <[email protected]> Co-authored-by: Wack <[email protected]> Co-authored-by: wackfx <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I'm a month late... 😓 Just to report some issues that might be worth to fix (it's still on master as of now)
Added a new function called
beginPrepared
to support prepared transactions.