[SERVER-55297] Short circuit $cond if condition is a constant Created: 18/Mar/21 Updated: 29/Oct/23 Resolved: 25/Aug/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 5.1.0-rc0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | David Percy | Assignee: | Alexander Ignatyev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||
| Sprint: | QE 2021-08-09 | ||||||||||||
| Participants: | |||||||||||||
| Description |
|
ExpressionCond::evaluate() only evaluates one or the other branch, depending on the value of the condition. We should have it do the same short-circuiting during optimize(). An expression like {$cond: [true, "$a", "$b"]} can be simplified to "$a", even though "$a" and "$b" are not constants. |
| Comments |
| Comment by Vivian Ge (Inactive) [ 06/Oct/21 ] |
|
Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you! |
| Comment by Githook User [ 10/Aug/21 ] |
|
Author: {'name': 'Alexander Ignatyev', 'email': 'alexander.ignatyev@mongodb.com', 'username': 'aligusnet'}Message: |
| Comment by David Percy [ 25/Mar/21 ] |
|
This is similar to $ifNull: |