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

Support partial list update (append) in state manager #1134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bushig
Copy link

@bushig bushig commented Feb 28, 2025

What's New

  • Added smarter handling of array operations with state management. Now when you append to arrays, Beanie uses MongoDB's $push operator rather than replacing the entire array.
  • Also some changes to docs to make cleaner why one would use state manager.
  • fixture to check what operations was actually sent to Mongo by motor, instead of using get_changes.

More details

  • Array append() operations now generate MongoDB $push operations with state_management=True
  • Only happens when state_management_replace_objects=False (which is the default)
  • Other array operations (changing items, removing them) still work as before, cause they unsafe for sure.
  • The get_changes() method still shows the full array for compatibility

Also thinking about adding option for unsafe direct array operations like changing elements by index, but still evaluating if its worth it.

@bushig bushig force-pushed the support_list_append_in_state_manager branch from 15385bf to 88d6001 Compare March 3, 2025 09:38
@bushig bushig force-pushed the support_list_append_in_state_manager branch from 88d6001 to 126b258 Compare March 3, 2025 12:03
@bushig
Copy link
Author

bushig commented Mar 3, 2025

Fixed tests, but there is still two failing because of docker hub image pull limits and one seems to be flaky test
Can anyone rerun failing tests?

@staticxterm
Copy link
Contributor

Hi @bushig, thanks for the PR.
I'll rerun the tests. Which reminds me that I should push some PR that would hopefully fix those flaky tests.
When I get some free time, I'll take a look at the PR.

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.

2 participants