-
Type: New Feature
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
There is a fair amount of implementation overhead for implementing both numeric addition and string concatenation with $add, and there are some related open tickets to fix: SERVER-6193, SERVER-6194.
Also I can see how '+' might be considered a convenience in javascript (though personally I would prefer a separate operator like '.'), but I'm not sure if there is a benefit in using the same $-expression to perform both addition and concatenation in the aggregation framework.
EDIT: $concat currently supports the following:
- All number types are converted to their string representation
- dates are converted to ISO-formatted strings
- code, symbol and string are already string types
- Null, undefined and missing fields ("nullish values") are converted to empty string
- timestamps are converted to ctime format + the increment portion. e.g., "Wed Jun 30 21:49:08 1993"
- all other types error out
- depends on
-
SERVER-6570 disallow $add with strings
- Closed
- is related to
-
SERVER-30461 aggregation $concat expression is inconsistent in type checking with all other string expressions
- Backlog
- related to
-
SERVER-6194 Nested $add operators may be improperly reordered by constant folding implementation
- Closed