Skip to content

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

Merged

Conversation

josenavas
Copy link
Contributor

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 in update_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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 79.08% when pulling 7f98288 on josenavas:fix-inconsistency-on-failure-updating into adff033 on biocore:master.

@squirrelo
Copy link
Contributor

One small comment.

@josenavas josenavas mentioned this pull request Apr 9, 2015
@josenavas josenavas added the bug label Apr 9, 2015
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 79.08% when pulling fa4273e on josenavas:fix-inconsistency-on-failure-updating into 3ad2264 on biocore:master.

value_type = type(value).__name__

if column_type != value_type:
if "invalid input syntax for" in str(e):
Copy link
Contributor

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.

@squirrelo
Copy link
Contributor

One comment.

@josenavas
Copy link
Contributor Author

This should be ready for final review/merge!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 79.07% when pulling f392de5 on josenavas:fix-inconsistency-on-failure-updating into 3aa8f73 on biocore:master.

@josenavas
Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@ElDeveloper
Copy link
Contributor

Looks good, but I think this might be missing some tests?

@josenavas
Copy link
Contributor Author

Thanks @ElDeveloper
I've added tests!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 79.07% when pulling a6d6989 on josenavas:fix-inconsistency-on-failure-updating into 3aa8f73 on biocore:master.

@ElDeveloper
Copy link
Contributor

Thanks @josenavas!

ElDeveloper added a commit that referenced this pull request Apr 13, 2015
…updating

Fix inconsistency on failure updating
@ElDeveloper ElDeveloper merged commit 8c6a90d into qiita-spots:master Apr 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants