-
Notifications
You must be signed in to change notification settings - Fork 79
Transfer update delete templates #2274
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
Changes from 25 commits
9481d42
998197e
656ac7f
37a5a74
4a6b3b2
0aaa53f
6f52ebd
c2e7d8b
c450079
22ce457
d2259b0
6ec24d9
e9901ed
2019e71
830312d
3f4cdcd
d9d51e6
4339eda
fa391d0
dd74e11
407fd8b
966eb0f
1a4026c
dc960a3
63519f6
eb2d314
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -646,9 +646,12 @@ def _raise_execution_error(self, sql, sql_args, error): | |
""" | ||
self.rollback() | ||
|
||
raise ValueError( | ||
"Error running SQL: %s. MSG: %s\n" % ( | ||
errorcodes.lookup(error.pgcode), error.message)) | ||
try: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block seems rather confusing, you There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found one case in which pgcodes was not in the error codes. It was mainly due to a bad usage of psycopg2 and the multiprocessing module. That is now fixed, but without this try/except I was unable to see the error message. Thus, in general they will be found, but just in case that in the future we find another issue, this will allow us to debug. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, that's very strange! |
||
ec_lu = errorcodes.lookup(error.pgcode) | ||
raise ValueError( | ||
"Error running SQL: %s. MSG: %s\n" % (ec_lu, error.message)) | ||
except KeyError: | ||
raise ValueError("Error running SQL query: %s" % error.message) | ||
|
||
@_checker | ||
def add(self, sql, sql_args=None, many=False): | ||
|
@@ -882,11 +885,13 @@ def rollback(self): | |
# Reset the queries, the results and the index | ||
self._queries = [] | ||
self._results = [] | ||
try: | ||
self._connection.rollback() | ||
except Exception: | ||
self._connection.close() | ||
raise | ||
|
||
if self._connection is not None and self._connection.closed == 0: | ||
try: | ||
self._connection.rollback() | ||
except Exception: | ||
self._connection.close() | ||
raise | ||
# Execute the post rollback functions | ||
self._funcs_executor(self._post_rollback_funcs, "rollback") | ||
|
||
|
@@ -937,3 +942,12 @@ def add_post_rollback_func(self, func, *args, **kwargs): | |
|
||
# Singleton pattern, create the transaction for the entire system | ||
TRN = Transaction() | ||
|
||
|
||
def create_new_transacion(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. transacion -> transaction There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
"""Creates a new global transaction | ||
|
||
This is needed when using multiprocessing | ||
""" | ||
global TRN | ||
TRN = Transaction() |
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.
this -> these
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.
Done