Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-8719

Wrong handling of `NumberLong` in query filter

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • No version
    • Affects Version/s: 1.45.0
    • Component/s: None
    • None
    • Environment:
      OS: MacOS 14.7.2
      node.js version: 20.18.0
      Additional info: Compass Version 1.45.0 (1.45.0)
    • Not Needed
    • Developer Tools

      Problem Statement/Rationale

      What is going wrong? What action would you like the Engineering team to take?

      • With the below filter entered manually to query a collection :
      { value: NumberLong(3359178440913756652) }
      

      The result returned is incorrect: NumberLong('3359178440913756672')

      • This is also visible when trying to export the result of the query, the input is wrongly converted to another number:

      db.getCollection('testing').find({
        value: NumberLong('3359178440913756672')
      });
      

      Steps to Reproduce

      How could an engineer replicate the issue you’re reporting?

      • use the below test documents:
      {
        "_id": 1,
        "value": {
          "$numberLong": "3359178440913756672"
        }
      },
      {
        "_id": 2,
        "value": {
          "$numberLong": "3359178440913756652"
        }
      }
      
      • query with the below filter:
      { value: NumberLong(3359178440913756652) }
      

      Expected Results

      What do you expect to happen?

      Returns:

      {
        "_id": 2,
        "value": {
          "$numberLong": "3359178440913756652"
        }
      }
      

      Actual Results

      What do you observe is happening?

      Returns:

      {
        "_id": 1,
        "value": {
          "$numberLong": "3359178440913756672"
        }
      }
      

        1. 2024-12-20_13-54.png
          28 kB
          Baptiste Blanchard
        2. 2024-12-20_13-57.png
          64 kB
          Baptiste Blanchard

            Assignee:
            Unassigned Unassigned
            Reporter:
            baptiste.blanchard@mongodb.com Baptiste Blanchard
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: