[SERVER-32861] Aggregation coercion to bool should not consider the empty string as true Created: 23/Jan/18  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Charlie Swanson Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: mql-semantics
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Assigned Teams:
Query Optimization
Participants:

 Description   

When used in a boolean concept, all strings are considered to be truthy. For example:

> db.foo.aggregate([{$project: {x: {$cond: {if: "", then: "hi", else: "bye"}}}}])
{ "_id" : ObjectId("5a31839ba9fb0c07a00ff123"), "x" : "hi" }

Most programming languages treat the empty string as "falsey". I think it would be less confusing for our users if we do the same.


Generated at Thu Feb 08 04:31:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.