[SERVER-31322] $dateToParts should name fields with same names as existing date expression operators Created: 29/Sep/17  Updated: 30/Oct/23  Resolved: 05/Oct/17

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 3.6.0-rc0

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Katherine Walker (Inactive)
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
is documented by DOCS-10856 rename fields returned by $dateToParts Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Repl 2017-10-23
Participants:

 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
	}
]



 Comments   
Comment by Githook User [ 05/Oct/17 ]

Author:

{'email': 'katherine.walker@mongodb.com', 'name': 'Katherine Walker', 'username': 'kvwalker'}

Message: SERVER-31322 Rename year and week field names for $dateToParts and $dateFromParts
Branch: master
https://github.com/mongodb/mongo/commit/b79c89cb665c85242607d66521fe1a2b91771188

Comment by Derick Rethans [ 02/Oct/17 ]

I believe this needs to be fixed, and the documentation as well as education lesson that are written need to be updated. So pinging kay.kim and norberto.leite so that they aware this is likely to change.

Generated at Thu Feb 08 04:26:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.