-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
feat(transaction): Adding withTransaction #519
Conversation
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.
Added some more comments.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #519 +/- ##
==========================================
- Coverage 61.74% 61.68% -0.06%
==========================================
Files 125 125
Lines 10089 10099 +10
==========================================
+ Hits 6229 6230 +1
- Misses 3860 3869 +9
|
/// - Parameter closure: A closure that uses the passed `PostgresConnection`. The closure **must not** capture | ||
/// the provided `PostgresConnection`. | ||
/// - Returns: The closure's return value. | ||
public func withTransaction<Result>(_ process: (PostgresConnection) async throws -> Result) async throws -> Result { |
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.
I wonder if we should capture calling file and line here. Then we could attach that info to the error that is thrown. We would wrap the thrown error in a PostgresTransactionError
. We could also attach the Rollback error, if that happens. cc @gwynne WDYT?
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.
Makes sense to me, yeah.
Co-authored-by: Fabian Fett <[email protected]>
Thanks @thoven87! Let's merge this and I'll do the error handling in a follow up! |
First pass at feature #512
What's the best way to go about writing unit test for the withTransaction func?