[SERVER-80021] Make $convert round-trip correctly between double and string Created: 15/Aug/23 Updated: 15/Nov/23 Resolved: 14/Sep/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.2.0-rc0, 5.0.22, 6.0.11, 7.1.0-rc4, 7.0.3, 4.4.26 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Adi Agrawal | Assignee: | Adi Agrawal |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Assigned Teams: |
Query Execution
|
||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||
| Backport Requested: |
v7.1, v7.0, v6.0, v5.0, v4.4
|
||||||||||||||||||||||||
| Steps To Reproduce: | db.c.aggregate([\{$project: {converted: {$convert: {input: 5909.123456, to: "string"}}}}]) gives 5909.12 . |
||||||||||||||||||||||||
| Sprint: | QE 2023-09-18 | ||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||||||||||
| Linked BF Score: | 138 | ||||||||||||||||||||||||
| Description |
|
We lose precision when we perform the conversion from double to string. Link to code. The default precision for a double in str::stream is set to 6 digits, which causes the loss of precision. This problem was identified in HELP-48955. We should change it so that we get a string representing the exact same doubleValue and can roundtrip and retrieve the same value back. We also want comprehensive and randomized tests to verify this behavior. |
| Comments |
| Comment by Githook User [ 26/Sep/23 ] |
|
Author: {'name': 'Adityavardhan Agrawal', 'email': 'adi.agrawal@mongodb.com', 'username': 'Adityav369'}Message: (cherry picked from commit 052ff0258ae00ed49e486e0a8acbffa81c7783d4)
(cherry picked from commit 39a130951177f23625ef56fec07aa49b4dc2878b) |
| Comment by Githook User [ 22/Sep/23 ] |
|
Author: {'name': 'Adityavardhan Agrawal', 'email': 'adi.agrawal@mongodb.com', 'username': 'Adityav369'}Message: (cherry picked from commit 052ff0258ae00ed49e486e0a8acbffa81c7783d4)
(cherry picked from commit 39a130951177f23625ef56fec07aa49b4dc2878b) |
| Comment by Githook User [ 20/Sep/23 ] |
|
Author: {'name': 'Adityavardhan Agrawal', 'email': 'adi.agrawal@mongodb.com', 'username': 'Adityav369'}Message: (cherry picked from commit 052ff0258ae00ed49e486e0a8acbffa81c7783d4) (cherry picked from commit 39a130951177f23625ef56fec07aa49b4dc2878b) |
| Comment by Githook User [ 20/Sep/23 ] |
|
Author: {'name': 'Adityavardhan Agrawal', 'email': 'adi.agrawal@mongodb.com', 'username': 'Adityav369'}Message: (cherry picked from commit 052ff0258ae00ed49e486e0a8acbffa81c7783d4)
(cherry picked from commit 39a130951177f23625ef56fec07aa49b4dc2878b) |
| Comment by Githook User [ 20/Sep/23 ] |
|
Author: {'name': 'Adityavardhan Agrawal', 'email': 'adi.agrawal@mongodb.com', 'username': 'Adityav369'}Message: (cherry picked from commit 052ff0258ae00ed49e486e0a8acbffa81c7783d4)
(cherry picked from commit 39a130951177f23625ef56fec07aa49b4dc2878b) |
| Comment by Githook User [ 14/Sep/23 ] |
|
Author: {'name': 'Adityavardhan Agrawal', 'email': 'adi.agrawal@mongodb.com', 'username': 'Adityav369'}Message: |