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

Case where updating array/map fields does not work #738

Closed
yoshizaki-aill opened this issue Mar 29, 2024 · 3 comments
Closed

Case where updating array/map fields does not work #738

yoshizaki-aill opened this issue Mar 29, 2024 · 3 comments

Comments

@yoshizaki-aill
Copy link

yoshizaki-aill commented Mar 29, 2024

I'm trying to upgrade Dynamoid 3.8.0 to 3.10.0.
Then, there was a case where the array field could not be updated.
(Also, the map type is the same.)

Field definition:

field :items, :array, { default: [] }

The following case cannot be saved. This looks confusing.

rec.items << 'foo'
rec.save!
pp rec.items
# ["foo"]
# This looks like it was saved.
pp rec.reload.items
# []
# But it's not actually persisted.

It works if I replace the whole (duplicated) array. However, this can be inconvenient for coding.

rec.items = ['foo']
rec.save!
pp rec.reload.items
# ["foo"]

new_arr = rec.items.dup
new_arr << 'bar'
rec.items = new_arr
rec.save!
pp rec.reload.items
# ["foo", "bar"]
@FinnIckler
Copy link

Maybe related to #666 ?

@andrykonchin
Copy link
Member

Yes, it seems a symptom of the same issue. Mutated collection/custom type isn't detected as a field change at persisting.

@yoshizaki-aill
Copy link
Author

Sorry for creating a duplicate issue.
I understood that this is an issue due to a differential update. I certainly think this is a difficult problem.
The affected parts of our source code have been fixed, so there is no problem.

Thank you.

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

No branches or pull requests

3 participants