-
Notifications
You must be signed in to change notification settings - Fork 18
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
cursor.get_cursor should return self #40
Comments
We're running afoul of liberapay/postgres.py#40
It shouldn't return itself, if it does then the transaction will be committed at the end of the inner |
I don't think this is a good idea, because it makes it easy to introduce subtle issues. Requiring explicit changes to support both DB and cursor objects in a function seems less likely to result in bugs. A method that explicitly supports DB and cursor objects can look like this: def foo(self, cursor=None):
(self.db or cursor).run("...") or that: def foo(self, cursor=None):
with self.db.get_cursor(cursor=cursor) as c:
... This second pattern currently isn't supported by |
This commit adds a `cursor` argument to the `get_cursor` method. The rationale for this is in <#40 (comment)>.
That will make it easier to interchange db and cursor objects. Cropped up at gratipay/gratipay.com#2729 (comment). Similar to #39.
The text was updated successfully, but these errors were encountered: