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

Add ignore_conflicts to bulk_create_with_history #733

Merged
merged 4 commits into from
Nov 13, 2020

Conversation

shihanng
Copy link
Contributor

@shihanng shihanng commented Nov 5, 2020

Description

If we are to support ignore_conflicts, we need to consider that not all item in the list of objects will be bulk created due to conflicts. Then, we also need to make sure that we create history records only for those objects that we created successfully. Unfortunately, we can't rely on the return value of bulk_create API because it returns all objects including those it ignores. Therefore, whenever ignore_conflicts=True we need to "force" the second transaction to query the created objects.

Related Issue

Close #732

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have run the make format command to format my code
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have added my name and/or github handle to AUTHORS.rst
  • I have added my change to CHANGES.rst
  • All new and existing tests passed.

@codecov
Copy link

codecov bot commented Nov 5, 2020

Codecov Report

Merging #733 (6dc1536) into master (c05255c) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #733   +/-   ##
=======================================
  Coverage   97.44%   97.44%           
=======================================
  Files          18       18           
  Lines         980      980           
  Branches      148      148           
=======================================
  Hits          955      955           
  Misses         12       12           
  Partials       13       13           
Impacted Files Coverage Δ
simple_history/utils.py 93.93% <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 c05255c...6dc1536. Read the comment docs.

@shihanng shihanng marked this pull request as ready for review November 6, 2020 11:59
@shihanng
Copy link
Contributor Author

shihanng commented Nov 6, 2020

Hi, I am opening this PR to propose a solution to #732. Please take a look and let me know what you think? Thank you.

@ThePumpingLemma
Copy link
Collaborator

@shihanng would you mind rebasing? Think it looks good otherwise but I'll let @rossmechanic chime in.

@shihanng
Copy link
Contributor Author

@ThePumpingLemma, rebased. Thank you.

Copy link
Collaborator

@ThePumpingLemma ThePumpingLemma left a comment

Choose a reason for hiding this comment

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

Thanks!

@ThePumpingLemma
Copy link
Collaborator

Not sure code climate is ever going to run. /shrug

@ThePumpingLemma ThePumpingLemma merged commit bf242a0 into jazzband:master Nov 13, 2020
@shihanng shihanng deleted the ignore-conflicts branch November 13, 2020 23:52
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.

Support ignore_conflicts parameter in bulk_create_with_history
2 participants