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

$dateToParts should name fields with same names as existing date expression operators

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.6.0-rc0
    • Component/s: Querying
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Epic Link:
    • Sprint:
      Repl 2017-10-23

      Description

      The $dateToParts expression operator return a document with "isoYear" and "isoWeekYear" fields that confusingly correspond to the return values of the $isoWeekYear and $isoWeek expression operators, respectively. I think we should change the $dateToParts expression operator to use the field names of "isoWeekYear" and "isoWeek" to match the behavior of the existing $isoWeekYear and $isoWeek expression operators.

      Note: We'll want to change $dateFromParts to take the "isoWeekYear" and "isoWeek" field names instead too.

      > db.mycoll.aggregate([{$addFields: {
        parts: {$dateToParts: {date: "$date", iso8601: true}},
        isoWeekYear: {$isoWeekYear: "$date"},
        isoWeek: {$isoWeek: "$date"},
      }}]).toArray()
      [
      	{
      		"_id" : ObjectId("59ce4f35ac2831cef80ed375"),
      		"date" : ISODate("2017-09-29T13:48:37.665Z"),
      		"parts" : {
      			"isoYear" : 2017,
      			"isoWeekYear" : 39,
      			"isoDayOfWeek" : 5,
      			"hour" : 13,
      			"minute" : 48,
      			"second" : 37,
      			"millisecond" : 665
      		},
      		"isoWeekYear" : NumberLong(2017),
      		"isoWeek" : 39
      	}
      ]
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              katherine.walker Katherine Walker (Inactive)
              Reporter:
              max.hirschhorn Max Hirschhorn
              Participants:
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: