Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-6195

consider $concat to concatenate strings instead of overloading $add

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.3.2
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      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

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            aaron Aaron Staple
            Votes:
            11 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: