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
Problem handling dots in DictField keys #2539
Comments
I think it's more of a python issue. We don't face the same issue when defining the field as an Embedded doc with its own class. |
@MarSoft is right, MongoEngine tracks the fields that are being changed through I'm not sure why the "dot-delimited" convention was chosen in the first place in _changed_fields, a tuple indeed sound like a better approach. I know it's useful for embedded fields and for list fields. I don't think it would be such a big work to do the change but there might be edge cases that I'm not considering here |
Is this issue still in 0.25.0 ? We use mongoengine in production and we have the same error I do not reproduce OP bug by testing locally. In what conditions is this crash occurring ? |
Seems to only be an issue with object.save() - object.update(field=updatedField) works |
We in the end had a problem with dots if field keys as well |
Consider the following code:
I think this should work, because MongoDB allows dots in dict key names as of version 3.6.
But in fact I get the following error:
After some digging I found that
_clear_changed_fields
takes list of string keys from_get_changed_fields()
where each key is a dot-delimited path into the object. Obviously this doesn't play well with keys containing dots.I think it would be safer to store keys as tuples rather than dot-delimited strings, but it will probably involve too many changes?
Tested with
MongoEngine==0.23.1
andpython 3.9.5
.The text was updated successfully, but these errors were encountered: