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

Do not change source object order when coping #313

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pawel-kordowski
Copy link

@pawel-kordowski pawel-kordowski commented Jan 27, 2024

In case when order_with_respect_to used and model instance copied by means of setting model_object.pk = None with changed wrt value, objects with the original wrt above got reordered.

Currently there are 2 possible workarounds:

  • set model_objects.order = None but it leads to an extra db query to set order
  • use bulk_create

@shuckc
Copy link
Member

shuckc commented Jan 29, 2024

The technique you've linked to isn't something I've been aware of. Surprisingly to see it documented - it's not at all nice reflected by the number of caveats in the docs.

I'll add a comment in the code to link to the docs, but this looks fine.

@shuckc shuckc force-pushed the fix/object-copy-sideeffects branch from 92aba39 to ab25af2 Compare January 29, 2024 11:04
@shuckc shuckc force-pushed the fix/object-copy-sideeffects branch from ab25af2 to 99f4a05 Compare January 29, 2024 11:06
@shuckc shuckc self-requested a review January 29, 2024 11:32
Copy link
Member

@shuckc shuckc left a comment

Choose a reason for hiding this comment

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

There's a problem demonstrated by 9fb8dc6 - q2_a3 has a duplicate order
If the user makes a copy without changing an ORT field, a new increased order value is required.

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

3 participants