[SERVER-68710] arrayEq/anyEq behave incorrectly with mongo shell types Created: 10/Aug/22  Updated: 29/Oct/23  Resolved: 13/Dec/22

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

Type: Bug Priority: Major - P3
Reporter: Yujin Kang Park Assignee: Yujin Kang Park
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File arrayEqTest.js    
Issue Links:
Depends
depends on SERVER-71572 Verify window_functions_on_timeseries... Closed
depends on SERVER-71574 Verify jstests/aggregation/sources/de... Closed
depends on SERVER-71575 Verify jstests/aggregation/sources/de... Closed
Related
related to SERVER-57605 Expose Decimal128 equality comparison... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Repro: arrayEqTest.js

Sprint: Execution Team 2022-12-12, Execution Team 2022-11-28, Execution Team 2022-12-26
Participants:

 Description   

In jstests/aggregation/extras/utils.js.

The function anyEq (and in turn arrayEq) considers mongo shell types (NumberLong/NumberInt/ObjectId, ...) elements as equal. This is caused by these having all properties as inherited, so no actual comparisons are made for the values within documentEq that arrayEq/anyEq uses to compare objects.

 

[js_test:arrayEqTest] dl NumberLong(4) dr NumberLong(5)
[js_test:arrayEqTest] property in dl floatApprox is own false
[js_test:arrayEqTest] property in dl top is own false
[js_test:arrayEqTest] property in dl bottom is own false
[js_test:arrayEqTest] property in dl exactValueString is own false
[js_test:arrayEqTest] property in dl tojson is own false
[js_test:arrayEqTest] documentEq: these are equal: NumberLong(4) == NumberLong(5)

[js_test:arrayEqTest] dl { "a" : NumberInt(1) } dr { "a" : NumberInt(1) }
[js_test:arrayEqTest] property in dl a is own true
[js_test:arrayEqTest] dl NumberInt(1) dr NumberInt(1)
[js_test:arrayEqTest] property in dl tojson is own false
[js_test:arrayEqTest] documentEq: these are equal: NumberInt(1) == NumberInt(1)
[js_test:arrayEqTest] anyEq: these are equal: NumberInt(1) == NumberInt(1)
[js_test:arrayEqTest] documentEq: these are equal: { "a" : NumberInt(1) } == { "a" : NumberInt(1) }
[js_test:arrayEqTest] anyEq: these are equal: { "a" : NumberInt(1) } == { "a" : NumberInt(1) }
[js_test:arrayEqTest] dl { "b" : NumberInt(2) } dr { "b" : NumberInt(4) }
[js_test:arrayEqTest] property in dl b is own true
[js_test:arrayEqTest] dl NumberInt(2) dr NumberInt(4)
[js_test:arrayEqTest] property in dl tojson is own false
[js_test:arrayEqTest] documentEq: these are equal: NumberInt(2) == NumberInt(4)
[js_test:arrayEqTest] anyEq: these are equal: NumberInt(2) == NumberInt(4)
[js_test:arrayEqTest] documentEq: these are equal: { "b" : NumberInt(2) } == { "b" : NumberInt(4) }
[js_test:arrayEqTest] anyEq: these are equal: { "b" : NumberInt(2) } == { "b" : NumberInt(4) }
[js_test:arrayEqTest] 2022-08-10T16:33:46.733Z assert failed : arrayEq not working as expected.



 Comments   
Comment by Githook User [ 12/Dec/22 ]

Author:

{'name': 'Yu Jin Kang Park', 'email': 'yujin.kang@mongodb.com', 'username': 'ykangpark'}

Message: SERVER-68710 Fix anyEq to properly compare mongo shell types
Branch: master
https://github.com/mongodb/mongo/commit/62530356433c6d602c6c38a7a4fce4b3657a2de2

Comment by Connie Chen [ 01/Nov/22 ]

We should take a first pass at this and if we uncover broken test file separate tickets to fix those tests.

Generated at Thu Feb 08 06:11:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.