-
Notifications
You must be signed in to change notification settings - Fork 80
Fix inconsistency on failure updating #1054
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
Fix inconsistency on failure updating #1054
Conversation
One small comment. |
…consistency-on-failure-updating
value_type = type(value).__name__ | ||
|
||
if column_type != value_type: | ||
if "invalid input syntax for" in str(e): |
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.
Something like this from search.py would probably be cleaner, since it directly connects the python datatype to the SQL datatype and the invalid syntax could be for other reasons besides type.
One comment. |
This should be ready for final review/merge! |
ping @biocore/qiita-dev |
def __setitem__(self, column, value): | ||
r"""Sets the metadata value for the category `column` | ||
def add_setitem_queries(self, column, value, conn_handler, queue): | ||
"""Adds the SQL queries needed to set and item to the queue |
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.
Can you rephrase this docstring, I don't think it makes sense.
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
Looks good, but I think this might be missing some tests? |
Thanks @ElDeveloper |
Thanks @josenavas! |
…updating Fix inconsistency on failure updating
This PR depends on #1050, review and merge that one first.Main motivation of the PR: the
update_category
function can leave the DB in an inconsistent state because the updates to the samples are done independently, so if one fails, the previous ones are already modified. By moving the__setitem__
queries to a function that adds them to a queue, we can use that function inupdate_category
to perform everything in a single transaction block.Also, in a previous PR, @squirrelo commented that the way types in the error were checked was probably not correct (for some reason I received that notification from github today). I tested it and @squirrelo was right, so I fixed it here. It is less elegant, but at least is correct.