-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat(db): add TransactionManager context manager #273
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
Conversation
Co-authored-by: lokomoti <40903296+lokomoti@users.noreply.github.com>
Reviewer's GuideThis PR introduces a TransactionManager context manager in the core DB module for automatic transaction lifecycle handling, refactors type stubs to centralize parameter behavior in a base class and mirror new functionality, and adds a style test environment in stubs/tox.ini for automated stub formatting checks. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes - here's some feedback:
- Wrap commitTransaction and rollbackTransaction calls in a try/finally to ensure closeTransaction is always invoked even if commit or rollback raises.
- Consider using None rather than an empty string as the default for the database parameter to better represent “no override” and align with the Optional[str] type hint.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Wrap commitTransaction and rollbackTransaction calls in a try/finally to ensure closeTransaction is always invoked even if commit or rollback raises.
- Consider using None rather than an empty string as the default for the database parameter to better represent “no override” and align with the Optional[str] type hint.
## Individual Comments
### Comment 1
<location> `incendium/src/incendium/db.py:206` </location>
<code_context>
super(OutParam, self).__init__(name_or_index, type_code)
+class TransactionManager(object):
+ """Database transaction context manager."""
+
</code_context>
<issue_to_address>
Consider handling exceptions during transaction commit/rollback more robustly.
Ensure system.db.closeTransaction is always called, even if commit or rollback raise exceptions, to prevent resource leaks.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| super(OutParam, self).__init__(name_or_index, type_code) | ||
|
|
||
|
|
||
| class TransactionManager(object): |
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.
suggestion (bug_risk): Consider handling exceptions during transaction commit/rollback more robustly.
Ensure system.db.closeTransaction is always called, even if commit or rollback raise exceptions, to prevent resource leaks.
Summary by Sourcery
Introduce a TransactionManager context manager to simplify transaction handling, update the stub files to reflect the new context manager and refactor parameter stubs to use a common base class, and add a style enforcement environment for stubs in tox.ini.
New Features:
Enhancements:
CI: