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

Improve or remove support for dates in string expressions

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.6.0-rc0
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • Minor Change
    • Query 2017-08-21, Query 2017-09-11, Query 2017-10-02, Query 2017-10-23

      A couple string expressions (notably in $substr(Bytes) and $concat) support dates as inputs, but do not include the number of milliseconds:

      > db.foo.insert({x: new Date()})
      WriteResult({ "nInserted" : 1 })
      > db.foo.find()
      { "_id" : ObjectId("56fae3003ef38a5ce210b230"), "x" : ISODate("2016-03-29T20:18:08.339Z") }
      > db.foo.aggregate({$project: {x: {$substr: ["$x", 0, 200]}}})
      { "_id" : ObjectId("56fae3003ef38a5ce210b230"), "x" : "2016-03-29T20:18:08" }
      

      We should either fix these places to include the number of milliseconds, or remove support for using these expressions with date types.

      One possible way forward is to add a $toString expression (related to SERVER-11400), then remove support and require an explicit conversion instead.

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: