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

DynamicField doesn't save as a ListField #2743

Open
dssecret opened this issue Mar 10, 2023 · 0 comments
Open

DynamicField doesn't save as a ListField #2743

dssecret opened this issue Mar 10, 2023 · 0 comments

Comments

@dssecret
Copy link

Updating a DynamicField of a list does not update using .save() or .cascade_save() when the list is updated using .append().

System Info

Ubuntu 20.04 LTS
MongoDB v6.0.4
mongoengine v0.26.0
pymongo v3.12.3

Reproducible Example
class ExampleModel(DynamicDocument):
    value = DynamicField()
Actual Result
>>> example = ExampleModel(value=[])
>>> example.value.append(1)
>>> example.save()
<ExampleModel: ExampleModel object>
>>> example.value
[1]
>>> example.reload()
<ExampleModel: ExampleModel object>
>>> example.value
[]
Expected Result
>>> example = ExampleModel(value=[])
>>> example.value.append(1)
>>> example.save()
<ExampleModel: ExampleModel object>
>>> example.value
[1]
>>> example.reload()
<ExampleModel: ExampleModel object>
>>> example.value
[1]
Work-Around
>>> example = ExampleModel(value=[])
>>> example.value.append(1)
>>> example.save()
<ExampleModel: ExampleModel object>
>>> a = list(example.value)
>>> a.append(1)
>>> example.value = a
>>> example.save()
>>> example.value
[1]
>>> example.reload()
<ExampleModel: ExampleModel object>
>>> example.value
[1]
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

1 participant