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
_id Type being changed to int32 after editing via json if it was initially inserted as int64 #2960
Comments
Same issue here |
@ToxicLand @abdudsoul Can you share screenshots of what exactly you are doing? In particular, the error message and the before/after state in the JSON viewer? |
@addaleax Sure. This first image shows that in the default view, _id type is Int64. https://i.imgur.com/uVVdUqV.jpg |
Thank you for bringing this up! I’ve opened https://jira.mongodb.org/browse/COMPASS-5711 (and the related, also regressed https://jira.mongodb.org/browse/COMPASS-5710) to track this. |
Fix various EJSON handling bugs by aligning our EJSON handling a bit more closely. This fixes regressions introduced by me in e654e1d (COMPASS-5710, COMPASS-5711 aka #2960) and another long-standing export bug (COMPASS-4694). Specifically, use `{ relaxed: false }` when parsing values into `HadronDocument`, and use `{ relaxed: false }` but undo the strict conversion for `$numberInt` and `$numberDouble`. This is a mode that we may eventually want to upstream into the Node.js driver’s `bson` package.
Fix various EJSON handling bugs by aligning our EJSON handling a bit more closely. This fixes regressions introduced by me in e654e1d (COMPASS-5710, COMPASS-5711 aka #2960) and another long-standing export bug (COMPASS-4694). Specifically, use `{ relaxed: false }` when parsing values into `HadronDocument`, and use `{ relaxed: false }` but undo the strict conversion for `$numberInt` and `$numberDouble`. This is a mode that we may eventually want to upstream into the Node.js driver’s `bson` package.
This should be fixed in the next release, thanks for reporting! |
@addaleax I just installed the latest release that fixed the type changing itself upon modifying the document, but if I want to change existing (affected by the bug) documents from Int32 to Int64 (like how it is for the rest of the documents) using the default view, I still get a "Plan executor error during findAndModify :: caused by :: Performing an update on the path '_id' would modify the immutable field '_id'". Currently the workaround for this is to switch to the json editor, and apply "_id": {"$numberLong": "3"}. |
@ToxicLand Yeah, that is honestly kind of expected, even if it might not be obvious why 😕 The table and “normal” document view use This does come with concrete downsides – for example, if the document was changed by something else in the background, this will still replace the entire document with whatever was in the JSON editor, rather than accounting for those other updates. The other editing modes don’t have this issue. I’ve opened https://jira.mongodb.org/browse/COMPASS-5753 for us to talk about this a bit further, but I can’t promise that we’ll make any changes here per se. |
Only since the latest GUI Update: When you edit the document via json editor, if the _id field type was int64, changing any field in the Json View Editor will cause the _id field type to change to int32.
When viewing the document via JSON Viewer the int64 _id field is being represented like:
{
"_id": 3
}
however in the previous version you could specify that it is int64 with this:
{
"_id": {
"$numberLong": "3"
}
}
if you try to specify it with $numberLong in the latest compass it will just give you error that it is not possible to edit an immutable field _id.
Environment
Possible Solution
Works fine in previous version that does not have the latest UI update
The text was updated successfully, but these errors were encountered: