[SERVER-32072] DBRef with NumberInt ID changing to float in the shell Created: 22/Nov/17 Updated: 30/Oct/23 Resolved: 01/Feb/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 3.2.7, 3.4.10, 3.6.0-rc4 |
| Fix Version/s: | 3.6.3, 3.7.2 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | simon hall | Assignee: | Mira Carey |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||
| Operating System: | ALL | ||||||||||||||
| Backport Requested: |
v3.6, v3.4, v3.2
|
||||||||||||||
| Steps To Reproduce: | Run the following commands from the shell or as shell scripts
|
||||||||||||||
| Sprint: | Platforms 2018-02-12 | ||||||||||||||
| Participants: | |||||||||||||||
| Description |
|
I have a issue when fetching and saving documents in the shell have a DBRef id that is a NumberInt If you insert this document and then view the document json is fine
But if you run a shell script that finds the document and then saves it again, the field "refInt" changes from
The field "int" does not change I have checked a few versions and have the same issue When running the steps to reproduce, if you run only step one, the data is fine, if you run Step 2, dbref id changes from int to float |
| Comments |
| Comment by Githook User [ 09/Feb/18 ] | |||||||||||||||||||||||||||||||||||||
|
Author: {'email': 'jcarey@argv.me', 'name': 'Jason Carey', 'username': 'hanumantmk'}Message: dbrefs in the shell can see silent casts from int -> float due to a lack For a fix, hook up the special lookup routines in js bsoninfo type into (cherry picked from commit edebe4d632290b991c291d5e0e0d8bb7e3f0428b) | |||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 01/Feb/18 ] | |||||||||||||||||||||||||||||||||||||
|
Author: {'email': 'jcarey@argv.me', 'name': 'Jason Carey', 'username': 'hanumantmk'}Message: dbrefs in the shell can see silent casts from int -> float due to a lack For a fix, hook up the special lookup routines in js bsoninfo type into | |||||||||||||||||||||||||||||||||||||
| Comment by Mira Carey [ 05/Dec/17 ] | |||||||||||||||||||||||||||||||||||||
|
After some code inspection, this is a bug dating back at least to the v8 -> spidermonkey upgrade (3.0). We have special logic inside of objects tagged as "bson" that we don't have for dbref and simply don't try as hard to preserve integer values. It can show up with some variability because an unrelated optimization avoids re-serialization of objects we haven't descended down into (i.e. if the print one of these objects, you'll definitely see the bug. If you never look at it, it will depend on how save/insert was implemented up above the c++ in js land). | |||||||||||||||||||||||||||||||||||||
| Comment by simon hall [ 28/Nov/17 ] | |||||||||||||||||||||||||||||||||||||
|
Hello, the output of your commands are the same on my system but I would like to focus more on the field 'refInt' for my issues with DBRef Looking at your example of searching by type I can better explain my issue Lets drop the collection, insert a fresh row and search for all documents that have a 32 bit integer for 'refInt.$id'
This brings back the record as expected Now lets fetch the record to 'var doc' and then save it
Now I use the same search as I used in the first block of code and it does not find any records
but an empty query will bring back the result
So it look like saving is changing the data type of DBRef ids if that id type starts off as NumberInt (int32) | |||||||||||||||||||||||||||||||||||||
| Comment by Ramon Fernandez Marina [ 27/Nov/17 ] | |||||||||||||||||||||||||||||||||||||
|
Thanks for your report plasticsnake. This is what I see in 3.4.10:
This is the behavior described in
above? Also, I checked the BSON type of the int field, and it's still an integer:
What are the outputs of the last two commands above for you? Does Thanks, |