Skip to content
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

feat bulk operation: don't crash on pristine document #32

Merged
merged 1 commit into from
Dec 2, 2020

Conversation

H--o-l
Copy link
Contributor

@H--o-l H--o-l commented Dec 2, 2020

Database.update_docs(ids=[...]) operation was working without crash only if
all documents were either modified or created.
But if only a subset of documents are really modified inside the bulk operation
it crashed with the error:

File "/var/coatl/lib64/python3.8/site-packages/aiocouch/bulk.py", line 59, in __aexit__
	assert status["id"] == doc.id
AssertionError

I think it's cool to improve it because:
If you have foo and baz documents in your db, and want to update both,
but foo already have the update. It's a nice shortcut to update both
without having to exclude foo from the bulk operation (see unit test for
an example).

`Database.update_docs(ids=[...])` operation was working without crash only if
all documents were either modified or created.
But if only a subset of documents are really modified inside the bulk operation
it crashed with the error:
```
File "/var/coatl/lib64/python3.8/site-packages/aiocouch/bulk.py", line 59, in __aexit__
	assert status["id"] == doc.id
AssertionError
```
I think it's cool to improve it because:
If you have `foo` and `baz` documents in your db, and want to update both,
but `foo` already have the update. It's a nice shortcut to update both
without having to exclude `foo` from the bulk operation (see unit test for
an example).
@codecov
Copy link

codecov bot commented Dec 2, 2020

Codecov Report

Merging #32 (240eb62) into master (510260c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #32   +/-   ##
=======================================
  Coverage   95.93%   95.93%           
=======================================
  Files          11       11           
  Lines         762      763    +1     
=======================================
+ Hits          731      732    +1     
  Misses         31       31           
Impacted Files Coverage Δ
aiocouch/bulk.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 510260c...240eb62. Read the comment docs.

Copy link
Member

@bmario bmario left a comment

Choose a reason for hiding this comment

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

Good catch, thanks. The change looks good to me.

@bmario bmario merged commit 56b31d5 into metricq:master Dec 2, 2020
@H--o-l
Copy link
Contributor Author

H--o-l commented Dec 2, 2020

Thanks @bmario for the quick review and merge!
Is it possible for you to upload a new release with this change in a "not to far" future?

@bmario
Copy link
Member

bmario commented Dec 3, 2020

Done.

@H--o-l
Copy link
Contributor Author

H--o-l commented Dec 3, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants