[SERVER-6120] Value::coerceToBool is inconsistent with javascript in some cases Created: 18/Jun/12 Updated: 11/Jul/16 Resolved: 03/Jul/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | 2.2.0-rc0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Aaron Staple | Assignee: | Aaron Staple |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Description |
|
Javascript treats empty strings and NaN as false, but Value::coerceToBool treats them as true. Test
Observed behavior: { $and:[ '' ] } evaluates to true. evaluates to false. |
| Comments |
| Comment by auto [ 03/Jul/12 ] | |||||
|
Author: {u'date': u'2012-07-02T16:08:27-07:00', u'name': u'Aaron', u'email': u'aaron@10gen.com'}Message: | |||||
| Comment by auto [ 03/Jul/12 ] | |||||
|
Author: {u'date': u'2012-07-02T16:05:27-07:00', u'email': u'aaron@10gen.com', u'name': u'Aaron'}Message: | |||||
| Comment by Eliot Horowitz (Inactive) [ 27/Jun/12 ] | |||||
|
Yeah - I think BSONElement::trueValue is actually what we want. | |||||
| Comment by Aaron Staple [ 26/Jun/12 ] | |||||
|
Also now that I look at it again this comment was what made me think js behavior was desired:
But I can change to make it based on BSONElement::trueValue | |||||
| Comment by Eliot Horowitz (Inactive) [ 26/Jun/12 ] | |||||
|
It should be BSONElement::trueValue | |||||
| Comment by Aaron Staple [ 25/Jun/12 ] | |||||
|
I don't have strong opinions about it. You might want to discuss with Andy. | |||||
| Comment by Mathias Stearn [ 22/Jun/12 ] | |||||
|
I'm not sure if we want JS semantics or BSONElement::trueValue or something else. Lets chat about this next thursday when I get back from MongoDC |