[SERVER-12970] agg functions which coerceToString do weird things with larger floats Created: 28/Feb/14  Updated: 06/Dec/22  Resolved: 01/Feb/18

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 2.4.9, 2.6.0-rc0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Asya Kamsky Assignee: Backlog - Query Team (Inactive)
Resolution: Won't Fix Votes: 0
Labels: usability
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-23410 Improve or remove support for dates i... Closed
Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

Some aggregation functions will turn any type into a string. This gives really strange results in an example like this:

db.foo.insert({i:1234567});   /* this is a float*/
db.foo.aggregate({$project:{_id:0, i:{$substr:["$i",0,3]}}}
{"i" : "1.2" }

Apparently it's because larger floats coerce to string of format 1.xxxe+xx

While $strcasecmp, $substr, $toLower and $toUpper all do this, only substr makes for such bizarre manifestation.


Generated at Thu Feb 08 03:30:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.