Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5649

Ensure BSON types are deep equal when containing the same value

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: BSON
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Use Case

      As a JS engineer
      I want to apply a BSON agnostic deep equality check to JS objects (documents)
      So that I do not need special methods or handling to determine if two BSON instances are equal.

      All BSON types should return true for util.isDeepStrictEqual if when serialized to BSON they result in the same byte sequence.

      User Impact

      • Should be none. Any changes needed should be internal.

      Dependencies

      • None

      Unknowns

      • BSON Binary tracks a position offset into a potentially much larger Uint8Array.
        • If I have a Binary([0,0,0]) with position 1 and Binary([0]) with position 1, they aren't deep equal but they are BSON equal.
      • Are there types other than binary that do not already satisfy this condition?

      Investigation

      •  Determine changes needed to each BSON type to satisfy the equality requirement

      Acceptance Criteria

      Implementation Requirements

      • Make changes to BSON types

      Testing Requirements

      • Generate BSON types that contain the same value but do not share any nested reference equality
        • assert isDeepStrictEqual for each type

      Documentation Requirements

      • Add documentation (to BSONValue?) describing the equality guarantee

      Follow Up Requirements

      • NODE-1392 may be a nice-to-have along with this change

            Assignee:
            Unassigned Unassigned
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: