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: add option to link existing objects of m2m fields instead of cloning them #752

Merged
merged 10 commits into from
Jan 30, 2023

Conversation

DanielSchaffer
Copy link
Contributor

@DanielSchaffer DanielSchaffer commented Jan 27, 2023

Closes: #703

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thanks for implementing a fix, could you ensure that the test covers your changes if applicable.

@codecov
Copy link

codecov bot commented Jan 27, 2023

Codecov Report

Merging #752 (df7dcea) into main (9dd89b3) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #752      +/-   ##
==========================================
+ Coverage   99.76%   99.77%   +0.01%     
==========================================
  Files           9        9              
  Lines         846      894      +48     
==========================================
+ Hits          844      892      +48     
  Misses          2        2              
Impacted Files Coverage Δ
model_clone/mixin.py 100.00% <100.00%> (ø)
model_clone/tests/test_clone_mixin.py 99.59% <100.00%> (+0.02%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

destination = getattr(duplicate, field.attname)

if all(
[

Check warning

Code scanning / Pylint (reported by Codacy)

Wrong hanging indentation before block (add 4 spaces).

Wrong hanging indentation before block (add 4 spaces).

for f in self._meta.many_to_many:
if any(
[

Check warning

Code scanning / Pylint (reported by Codacy)

Wrong hanging indentation before block (add 4 spaces).

Wrong hanging indentation before block (add 4 spaces).
):
fields.add(f)

for f in self._meta.related_objects:

Check warning

Code scanning / Pylint (reported by Codacy)

Variable name "f" doesn't conform to snake_case naming style

Variable name "f" doesn't conform to snake_case naming style
for f in self._meta.related_objects:
if f.many_to_many:
if any(
[

Check warning

Code scanning / Pylint (reported by Codacy)

Wrong hanging indentation before block (add 4 spaces).

Wrong hanging indentation before block (add 4 spaces).
@DanielSchaffer
Copy link
Contributor Author

Man, all these checks are nice! 👏

I'll fix the coverage and remaining linting in a bit.

@DanielSchaffer
Copy link
Contributor Author

@jackton1 looks like that pre-commit.ci check is having a problem - I don't think this is anything this PR is doing, any ideas?

       RuntimeError: The Poetry configuration is invalid:
           - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'

https://results.pre-commit.ci/run/github/172541739/1675087809.NoG7DgCwSrG2-ErufHjEBw

@jackton1
Copy link
Member

@jackton1 looks like that pre-commit.ci check is having a problem - I don't think this is anything this PR is doing, any ideas?

       RuntimeError: The Poetry configuration is invalid:
           - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'

results.pre-commit.ci/run/github/172541739/1675087809.NoG7DgCwSrG2-ErufHjEBw

Yep there's some issue with the isort package I'll fix that up now.

@jackton1 jackton1 added automerge merge when passing Merge the PR automatically once all status checks have passed labels Jan 30, 2023
@jackton1
Copy link
Member

@all-contributors please add @DanielSchaffer for code, test

@allcontributors
Copy link
Contributor

@jackton1

I've put up a pull request to add @DanielSchaffer! 🎉

@repo-ranger repo-ranger bot merged commit ef963c1 into tj-django:main Jan 30, 2023
@DanielSchaffer DanielSchaffer deleted the support-linking-m2m-fields branch January 30, 2023 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge merge when passing Merge the PR automatically once all status checks have passed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Create m2m relations with existing objects new.m2mfield.set(old.m2mfield.all())
2 participants