Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-91763

Shell does not evaluate comparison operators correctly for NumberDecimal

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • ALL

      The greater than and less than operator that compare NumberDecimals against each other seem to compare the string value rather than the actual numeric values against each other. See this repro:

      Less than operator:

       

       build/install/bin/mongo --nodb
      ================ Welcome to the MongoDB shell
      > let v1 = NumberDecimal("11"); 
      > let v2 = NumberDecimal("2"); 
      > let lt = v1 < v2; 
      > lt 
      true

      Greater than operator:

       

       > build/install/bin/mongo --nodb
      ================ 
      > let v1 = NumberDecimal("11"); 
      > let v2 = NumberDecimal("2"); 
      > let gt = v1 > v2;
      > gt
      false

            Assignee:
            erin.liang@mongodb.com Erin Liang
            Reporter:
            erin.liang@mongodb.com Erin Liang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: