[SERVER-30773] bsonWoCompare and bsonBinaryEqual should work with bsonelement types Created: 22/Aug/17  Updated: 30/Oct/23  Resolved: 04/Oct/18

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: None
Fix Version/s: 4.0.4, 4.1.5

Type: Bug Priority: Minor - P4
Reporter: Mira Carey Assignee: Annie Black
Resolution: Fixed Votes: 3
Labels: service_architecture
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
Related
related to SERVER-37376 Increase task timeout for the update ... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.0
Sprint: Service Arch 2018-10-08
Participants:
Linked BF Score: 42

 Description   

bsonWoCompare and bsonBinaryEqual check to see if their arguments are objects (which they are for our exposed bson types), before converting them to bson and then dispatching to underlying bson methods.

This inappropriately shows any special two non-top-level bson values as equal (without throwing) as they convert as general objects (with no actual fields). For some objects, like timestamp, this works (as they store their state as js visible fields). For others, like numberlong or bindata, it does not.

It appears that we have instances of both patterns in current jstests, so it may be advantageous to check for the bson element types, and wrap the objects in that case.

If we don't want to make them work correctly, we should at least throw for broken types



 Comments   
Comment by Githook User [ 19/Oct/18 ]

Author:

{'name': 'ablack12', 'email': 'annie.black@10gen.com', 'username': 'ablack12'}

Message: SERVER-30773 optimize bsonWoCompare/bsonBinaryEqual

(cherry picked from commit 2d379ce39872fdfc04e6775ed8adea7ccdd1d1c1)
Branch: v4.0
https://github.com/mongodb/mongo/commit/4580674ce98a355218afbfdf67ebf0f406d04c25

Comment by Githook User [ 02/Oct/18 ]

Author:

{'name': 'ablack12', 'email': 'annie.black@10gen.com', 'username': 'ablack12'}

Message: SERVER-30773 optimize bsonWoCompare/bsonBinaryEqual
Branch: master
https://github.com/mongodb/mongo/commit/2d379ce39872fdfc04e6775ed8adea7ccdd1d1c1

Comment by Annie Black [ 02/Oct/18 ]

https://mongodbcr.appspot.com/215850001/

Comment by Githook User [ 26/Sep/18 ]

Author:

{'name': 'ablack12', 'email': 'annie.black@10gen.com', 'username': 'ablack12'}

Message: SERVER-30773 add functionality for bson element types
Branch: master
https://github.com/mongodb/mongo/commit/cf23fa5157af746f5600c7a64eec9f02161b3199

Comment by Kyle Suarez [ 30/Jan/18 ]

This would be very helpful when writing tests. For example, I often execute queries with a sort and then make an assertion on the final sort order, which makes me resort to hacks like

assert.eq(coll.find().sort({_id: 1}),
          someArrayOfObjs.sort((d1, d2) => bsonWoCompare({_: d1._id}, {_: d2._id})));

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