[SERVER-63316] Object.extend should handle Date objects Created: 01/Feb/22  Updated: 15/May/23  Resolved: 15/May/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: David Percy Assignee: David Percy
Resolution: Duplicate Votes: 0
Labels: quick-tech-debt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
duplicates SERVER-59163 Enable partial indexes on time-series... Closed
Related
related to SERVER-59163 Enable partial indexes on time-series... Closed
is related to SERVER-40425 fix Object.extend() for all custom ja... Backlog
Participants:
Linked BF Score: 31

 Description   

Expected:

> Object.extend({}, {d: new Date()}).d
ISODate("2022-02-04T18:37:47.961Z")

Actual:

> Object.extend({}, {d: new Date()}, true).d
uncaught exception: TypeError: this.getTime is not a function :
Date.prototype.tojson@src/mongo/shell/types.js:44:9
shellPrintHelper@src/mongo/shell/utils.js:682:15
@(shell2):1:1

I noticed and fixed this on 5.3 while doing SERVER-59163, but I think we should backport it too.



 Comments   
Comment by David Percy [ 15/May/23 ]

It looks like I had actually already addressed this specific case as part of SERVER-59163: https://github.com/mongodb/mongo/commit/610898a1ccec0afc3d38f7c29f2553d5b6102d30#diff-443e6133593597e6629120bef14e1c39fdf5fc9a05240460d77b26691f8daa5aR280

Comment by Max Hirschhorn [ 04/Feb/22 ]

There are many types which are built into the mongo shell and cannot be copied via Object.extend() (see also SERVER-61079). I don't think creating one-off tickets to handle each type as it happens to come up is a good strategy. Would the Query team be interested in picking up SERVER-40425?

Generated at Thu Feb 08 05:57:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.